How to detect if a point is contained within a bounding rect - opecv & python
def rectContains(rect,pt):
logic = rect[0] < pt[0] < rect[0]+rect[2] and rect[1] < pt[1] < rect[1]+rect[3]
return logic
rect = (a,b,c,d)
rectContains(rect,pt)
- a,b are the top-left coordinate of the rectangle and (c,d) be its width and height. OpenCV Contour Features
- to judge a point(x0,y0) is in the rectangle, just to check if a < x0 < a+c and b < y0 < b + d