我正在使用在模板匹配上使用OpenCV的项目,并且我想限制图像上的搜索区域.从相机连续捕获图像.
I'm working on a project using OpenCV on template matching, and I want to limit the search region on an image. Image is captured continuously from a camera.
是否有任何方法可以将定义在ROI之外的图像归零/遮罩,以便模板匹配过程可以针对剩余区域进行特定设置,从而更快,更准确?
Is there any way to Zero / mask out image outside ROI defined, so that template matching process can be specific on remaining region, faster and accurate?
推荐答案看看 cvSetImageROI 函数.
void cvSetImageROI(IplImage* image, CvRect rect)
void cvSetImageROI(IplImage* image, CvRect rect)
为给定的矩形设置图像感兴趣区域(ROI). 参数:
Sets an image Region Of Interest (ROI) for a given rectangle. Parameters:
- image –指向图像标题的指针
- rect – ROI矩形
如果原始图像的ROI为NULL,并且 直肠不是整个形象, 分配了ROI结构.
If the original image ROI was NULL and the rect is not the whole image, the ROI structure is allocated.
大多数OpenCV函数都支持使用 ROI并处理图像矩形 作为单独的图像.例如,全部 像素坐标的计数 从左上角(或左下角)开始 ROI的一角,不是原始的 图片.
Most OpenCV functions support the use of ROI and treat the image rectangle as a separate image. For example, all of the pixel coordinates are counted from the top-left (or bottom-left) corner of the ROI, not the original image.
更多推荐
遮罩/归零区域超出指定的ROI
发布评论