How to detect if a point is contained within a bounding rect - opecv & python

Nimrodshn picture Nimrodshn · Oct 11, 2015 · Viewed 20.4k times · Source

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

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. what is the meaning of these four numbers?.

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

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

Answer

Hooting picture Hooting · Oct 11, 2015
  1. a,b are the top-left coordinate of the rectangle and (c,d) be its width and height. OpenCV Contour Features
  2. to judge a point(x0,y0) is in the rectangle, just to check if a < x0 < a+c and b < y0 < b + d