0

Given and image and 4 corner points of an area inside the image, I want to figure out if a point p (x,y) lays inside the given area. The area is not necessarily in form of a rectangle, as the area is the result of a perspective projection of some other image.

For example:

enter image description here

Here I want to figure out if the pink point actually lays within the shape inside the image. In this case it does.

I was thinking about drawing an contour with drawContours and then using pointPolygonTest but I was wondering if there is an easier and more tailored way of doing it.

a6i09per5f
  • 260
  • 1
  • 15
  • 1
    Why would you draw anything? `pointPolygonTest` works on a list of 2D coordinates that define the contour, not an image. – Dan Mašek Nov 29 '22 at 21:31
  • For convex shape, you can do by checking sign of cross product. – fana Nov 30 '22 at 07:05
  • How to create a contour from a list of points: https://stackoverflow.com/questions/14161331/creating-your-own-contour-in-opencv-using-python Then run pointPolygonTest() on that. – nick Nov 30 '22 at 08:40

0 Answers0