c++ - 如何在 OpenCv 中轻松检测 2 个 ROI 是否相交?

标签 c++ opencv roi

我正在尝试检测 2 个感兴趣区域 (CvRects) 在 OpenCV 中是否相互交叉。我显然可以手动输入几个(或者说很多)要检查的条件,但这并不是一个很好的方法(imo)。

谁能建议我任何其他解决方案? OpenCV中是否有现成的方法?

最佳答案

我不知道有什么现成的C接口(interface)解决方案(CvRect),但是如果你使用C++方式(cv::Rect),你很容易说出来

interesect  = r1 & r2;

complete list对矩形的操作是

// In addition to the class members, the following operations 
// on rectangles are implemented:

// (shifting a rectangle by a certain offset)
// (expanding or shrinking a rectangle by a certain amount)
rect += point, rect -= point, rect += size, rect -= size (augmenting operations)
rect = rect1 & rect2 (rectangle intersection)
rect = rect1 | rect2 (minimum area rectangle containing rect2 and rect3 )
rect &= rect1, rect |= rect1 (and the corresponding augmenting operations)
rect == rect1, rect != rect1 (rectangle comparison)

关于c++ - 如何在 OpenCv 中轻松检测 2 个 ROI 是否相交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8714101/

相关文章:

c++ - C++0x 的计划发布日期是什么时候?

python - opencv/ python : Draw image over a webcam stream

matlab - 在图像上绘制多个区域 - imfreehand

python - 如何用图像中每个像素的颜色绘制图形?

c++ - 使用 OpenCV C++ 从黑白图像中提取四边形的角点(极角点)

image - ROI以比原始图片更浅的颜色书写

python - 如何根据上下粉色范围查找roi_corners,以便可以在python中使用opencv对其进行模糊处理

c++ - Ubuntu 上 Boost program_options 代码中的链接错误

c++ - Qt GLSL纹理只出现一种颜色

c++ - NetShareEnum (..) winapi 无法删除不必要的共享文件夹