foolwood / SiamMask

[CVPR2019] Fast Online Object Tracking and Segmentation: A Unifying Approach
http://www.robots.ox.ac.uk/~qwang/SiamMask
MIT License
3.47k stars 817 forks source link

How to create Axis-aligned bounding boxes #141

Open SamihaSara opened 4 years ago

SamihaSara commented 4 years ago

I am trying to get axis-aligned bounding box where the original algorithm used rotated bounding boxes. corresponding lines are -- if len(contours) != 0 and np.max(cnt_area) > 100: contour = contours[np.argmax(cnt_area)] # use max area polygon polygon = contour.reshape(-1, 2) pbox = cv2.boundingRect(polygon) # Min Max Rectangle

pbox = cv2.boxPoints(cv2.minAreaRect(polygon))

        box_in_img = pbox
        state['ploygon'] = rbox_in_img if mask_enable else []

location = state['ploygon'].flatten()

But getting the following error:

image

Then if I delete the flatten() function in demo.py, I do not get errors but bounding boxes are not correct. image

Please give me some suggestion to solve this issue.