我想做一件非常简单的事情:将图像中的一个区域复制到新图像的一个新区域。在OpenCV 2.3的备忘单中,他们建议使用以下解决方案:
"示例3. 将图像ROI转换并复制到另一个图像"
Rect r(1, 1, 10, 20);
Mat dstroi = dst(Rect(0,10,r.width,r.height));
src(r).convertTo(dstroi, dstroi.type(), 1, 0);
我的代码如下:
Mat frameO, frameS;
original >> frameO;
stabilized >> frameS;
Mat output(frameO.rows+40, frameO.cols*2+60, CV_32FC3);
output.setTo(0);
Rect r(0,0, frameO.cols, frameO.rows);
Mat destROI = output(Rect(20,20, frameO.cols, frameO.rows));
frameO(r).copyTo(destROI);
我想将输出中的图像 frameO
复制到位置为 Rect(20,20, frameO.cols, frameO.rows)
的区域。
有人能告诉我为什么它不起作用吗?