我正在尝试检测 2 个感兴趣区域 (CvRect
s) 在 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/