重塑矩阵在OpenCV 2.4.3中失败 [英] reshaping a matrix failed in OpenCV 2.4.3
本文介绍了重塑矩阵在OpenCV 2.4.3中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用OpenCV 2.4.3创建和重塑矩阵,如下所示:
I am using OpenCV 2.4.3 to create and reshape a matrix like this:
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中多次使用了重塑"功能,但是在这个新版本中,我看不到任何更改.这是一个错误吗?还是我在这里使用不正确?
Then from the output, I see there is no change for the reshaped testMat. I used "reshape" many times in older version of OpenCV, but with this new version, I couldn't see any changes. Is this a bug? Or am I using it incorrectly here?
推荐答案
reshape返回新的Mat标头
reshape returns a new Mat header
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;
这篇关于重塑矩阵在OpenCV 2.4.3中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文