I would like to know how I can get an opencv rect object by providing two Points. The c++ version provides this datastructre.
<a href="http://docs.opencv.org/java/2.4.9/org/opencv/core/Rect.html" rel="nofollow">http://docs.opencv.org/java/2.4.9/org/opencv/core/Rect.html</a>
I cant find a way to instantiate rects in python.
cv2.Rect(p1,p2) but this method seems not be existent.
Is it even possible?
Thanks in adavance :)Answer1:
Look for example at this tutorial face detection <a href="http://docs.opencv.org/trunk/d7/d8b/tutorial_py_face_detection.html" rel="nofollow">http://docs.opencv.org/trunk/d7/d8b/tutorial_py_face_detection.html</a> and you'll see that in Python opencv bindings rectangles are tuples/lists of the four coordinates - the results of, for example, faceCascade.detectMultiScale is a list of these - basically, use normal Python capabilities to manage them.
I guess you'll have to write your own overlap/area/contains functions - not terribly diificult - or see other answers here, for example <a href="https://stackoverflow.com/questions/25068538/intersection-and-difference-of-two-rectangles/25068722#25068722" rel="nofollow">Intersection and difference of two rectangles</a>
UPDATE - my bad, the rectangles returned by detectMultiScale are (x,y,w,h)