point inside rect
I have a rectangle of size l*b where one edge is present at p0 and opposite at p1. How do i check if a point/pixel pi is inside this rectangle or not?
I have a rectangle of size l*b where one edge is present at p0 and opposite at p1. How do i check if a point/pixel pi is inside this rectangle or not?
you can use contains method too
you should compare your point x and y coordinates with rectangle points, so if the p0 is the top-left vertex of the rectangle and p1 bottom-right then
1. p0 x coordinate < point x < p1 x coordinate
2. p0 y coordinate < point y < p1 y coordinate
if those conditions are satisfied then the point is inside the rectangle
the rectangle is present at some angle with x axis i.e it is not parrallel to any axix.
in this case, I suggest creating a contour
from that rectangle points which seems possible (see here ) and then use pointPolygonTest
. pointPolygonTest function determines whether the point is inside a contour, outside, or lies on an edge (or coincides with a vertex). It returns positive (inside), negative (outside), or zero (on an edge) value, correspondingly. (see here)
Asked: 2020-01-22 14:21:21 -0600
Seen: 7,037 times
Last updated: Jan 23 '20
How do I draw irregular contours of MSER regions
MSER Sample in OpenCV 2.4.2 on Visual Studio 2012
Using Open CV with a Network IP Camera
shape context implementation in opencv
What's the best way to match forms of line drawing?
drawing 3D optical flow with opencv
How to Expand contour similar dilatation of contour?