opencv检测相交点,如何轻松地检测2个ROIs是否相交在OpenCv?

I am trying to detect whether 2 Regions of Interest (CvRects) are intersecting one another in OpenCV. I can obviously manually type several (or rather a lot of) conditions to be checked but that wouldn't really be a good way to do it (imo).

Can anyone suggest me any other solution? Is there a ready method in OpenCV for that ?

解决方案

I do not know of any ready-made solution for the C interface (CvRect), but if you use the C++ way (cv::Rect), you can easily say

interesect = r1 & r2;

The complete list of operations on rectangles is

// 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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值