参考 OpenCV - Convert vector of vector to Mat
//If you want to temporary copy a big chunk of std:vector of std::vector data to cv::Mat
//without copying, the most efficient is:
std::vector<std::vector<float> > OrigSamples;
...
... // Here OrigSamples is filled with some rows with the same row size
...
// Create a new, _empty_ cv::Mat with the row size of OrigSamples
cv::Mat NewSamples(0, OrigSamples[0].size(), cv::DataType<float>::type);
for (unsigned int i = 0; i < OrigSamples.size(); ++i)
{
// Make a temporary cv::Mat row and add to NewSamples _without_ data copy
cv::Mat Sample(1, OrigSamples[0].size(), cv::DataType<float>::type, OrigSamples[i].data());
NewSamples.push_back(Sample);
}