【发布时间】:2014-06-29 13:37:11
【问题描述】:
我写了一些代码来在图像的左右两侧添加 10% 的灰色条,如下所示:
// Create image 20% wider
cv::Mat widenedImage(image.rows,
image.cols * 1.2,
CV_8UC1,
127); // Grey colour
// Make a region of interest in the middle of the new image
cv::Mat toROI(widenedImage, cv::Rect((widenedImage.cols - image.cols) / 2.0,
0,
image.cols,
image.rows));
// Copy the image to the region of interest
image.copyTo(toROI);
无需代码,直接使用image,应用运行良好。添加后,XCode 的内存图不会增长,但我收到了几个警告,然后是这条消息。
有什么想法吗?
【问题讨论】:
-
图片的类型是CV_8UC1?
-
@Robert:你能不能也分享一下警告信息。此外,您是否可以尝试使用尺寸小于当前图像的图像。
-
您是否尝试过在
cv::Rect()之前和widenedImage.. 中的列初始化期间使用static_cast<size_t>? -
@marol - 是的,所有图像都是一个通道的 8 位图像。我还仔细检查了
NSAssert(image.type()== CV_8UC1, @"");。 -
@MantoshKumar - 消息在屏幕截图中。图像是来自相机的一帧,我真的不想对其进行下采样。