How to perform intersection or union operations on a rect in Python?
I saw a question that is solved by using &
(intersection) on rectangles http://answers.opencv.org/question/67...
I am trying to do the same in python.
I draw the rectangles like this:
for rect in rects_new:
#print (str(type(rect))) #<class 'numpy.ndarray'>
#print (rect.area()) # gives error that 'numpy.ndarray' object has no attribute 'area'
cv2.rectangle(vis, (rect[0],rect[1]), (rect[0]+rect[2],rect[1]+rect[3]), (0, 255, 255), 2)
but the rectangles are overlapping. I would only like to keep the outermost rectangle. However, I don't know how to perform &
intersect operations. I can't even call area()
on it.
take a look at cv2.groupRectangles