如何检测一个点是否包含在一个边界矩形内 - opecv &Python [英] How to detect if a point is contained within a bounding rect - opecv & python

查看:95
本文介绍了如何检测一个点是否包含在一个边界矩形内 - opecv &Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组点 [(x0,y0), (x1,y1), .. ]

I have a set of points [(x0,y0), (x1,y1), .. ]

以及使用 cv2.boundingRect(someContour) 函数生成的一组边界矩形.其中每个边界框都是一个具有四个坐标 (a,b,c,d) 的可迭代对象.我的问题是:

And a set of bounding rectangles produced using the cv2.boundingRect(someContour) function. Where each bounding box is an iterable object with four coordinates (a,b,c,d). My questions are:

  1. 这四个数字是什么意思?

  1. what is the meaning of these four numbers?.

如何检查每个给定点是否包含在边界矩形内?

how to check if each given point is contained within the bounding rect?

我知道 C++ 的 opencv 有 'contains' 方法,但它不存在于 python.

I know that opencv for C++ has the 'contains' method but it doesnt exist for python.

推荐答案

  1. a,b 是矩形的左上角坐标,(c,d) 是它的宽度和高度.OpenCV 轮廓特征立>
  2. 判断一个点(x0,y0)是否在矩形内,只要检查a <x0<a+c 和 b

这篇关于如何检测一个点是否包含在一个边界矩形内 - opecv &amp;Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆