我正在使用OpenCV 2.4.3来创建和重塑这样的矩阵:
cv::Mat testMat = cv::Mat::zeros ( 500, 200, CV_8UC3 );
std::cout << "size of testMat: " << testMat.rows << " x " << testMat.cols << std::endl;
testMat.reshape ( 0, 1 );
std::cout << " size of reshaped testMat: " << testMat.rows << " x " << testMat.cols << std::endl;
然后从输出中,我看到重新形成的testMat没有变化。我在旧版本的OpenCV中多次使用“reshape”,但是对于这个新版本,我看不到任何变化。这是一个错误吗?或者我在这里错误地使用它?
答案 0 :(得分:4)
reshape返回一个新的Mat标头
cv::Mat testMat = cv::Mat::zeros ( 500, 200, CV_8UC3 );
std::cout << "size of testMat: " << testMat.rows << " x " << testMat.cols << std::endl;
cv::Mat result = testMat.reshape ( 0, 1 );
std::cout << " size of original testMat: " << testMat.rows << " x " << testMat.cols << std::endl;
std::cout << " size of reshaped testMat: " << result.rows << " x " << result.cols << std::endl;