0

I would like to get if a polyline and rectangle intersect on opencv+Python:

A = cv2.rectangle(frame,(384,0),(510,128),(0,255,0),3)
pts = np.array([[1300,900],[1750,700],[1000,200],[600,200]], np.int32)
pts = pts.reshape((-1,1,2))
B = cv2.polylines(frame,[pts],True,(244,66,66),7)

How can I find if A intersect with B? Thank you

Jeru Luke
  • 16,909
  • 11
  • 66
  • 79
user3925023
  • 605
  • 4
  • 21
  • 1
    easiest is probably to draw each one on irs own image and compute the intersection. But other methods will be faster to process. – Micka Jul 23 '18 at 14:53

1 Answers1

1

Opencv and Numpy don't have direct geometry intersection functions. You can write your own (see Numpy and line intersections) or a common technique is to draw the rectangle filled with a color and then check if the points along the line on the same image are that color.

Martin Beckett
  • 92,791
  • 27
  • 183
  • 258