Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to create Axis-aligned bounding boxes using Flatten()

I am trying to get axis-aligned bounding box by commenting out some lines in the original project(https://github.com/foolwood/SiamMask). These lines are -- pbox = cv2.boundingRect(polygon) # Min Max Rectangle box_in_img = pbox. But getting the following error: tuple object doesnot have flatten. but flatten() previously worked with rotated bounding boxes. If I remove flatten to execute the code, the error is gone but I am getting wrong bounding boxes like this--

image description

I have matched results in every steps of axis aligned to rotated bounding box version, they match completely, just the flatten() does not work. Please give some ideas to solve this issue.

click to hide/show revision 2
None

updated 2020-02-19 02:14:48 -0600

berak gravatar image

How to create Axis-aligned bounding boxes using Flatten()

I am trying to get axis-aligned bounding box by commenting out some lines in the original project(https://github.com/foolwood/SiamMask). project. These lines are -- pbox = cv2.boundingRect(polygon) # Min Max Rectangle box_in_img = pbox. But getting the following error: tuple object doesnot have flatten. but flatten() previously worked with rotated bounding boxes. If I remove flatten to execute the code, the error is gone but I am getting wrong bounding boxes like this--

image description

I have matched results in every steps of axis aligned to rotated bounding box version, they match completely, just the flatten() does not work. Please give some ideas to solve this issue.

click to hide/show revision 3
None

updated 2020-02-19 02:16:01 -0600

berak gravatar image

How to create Axis-aligned bounding boxes using Flatten()

I am trying to get axis-aligned bounding box by commenting out some lines in the original project. These lines are -- --

pbox = cv2.boundingRect(polygon) # Min Max Rectangle
box_in_img = pbox.

But getting the following error: tuple object doesnot have flatten. but flatten() previously worked with rotated bounding boxes. If I remove flatten to execute the code, the error is gone but I am getting wrong bounding boxes like this--

image description

I have matched results in every steps of axis aligned to rotated bounding box version, they match completely, just the flatten() does not work. Please give some ideas to solve this issue.

How to create Axis-aligned bounding boxes using Flatten()

I am trying to get axis-aligned bounding box by commenting out some lines in where the original project. These 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.

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

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

But getting the following error: tuple object doesnot have flatten. but flatten() previously worked with rotated bounding boxes. If I remove flatten to execute the code, the error is gone but I am getting wrong bounding boxes like this--

image description

I have matched results in every steps of axis aligned to rotated bounding box version, they match completely, just the flatten() does not work. Please give some ideas to solve this issue.

click to hide/show revision 5
None

updated 2020-02-20 00:16:46 -0600

berak gravatar image

How to create Axis-aligned bounding boxes using Flatten()

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()

state['ploygon'].flatten()

But getting the following error: tuple object doesnot have flatten. but flatten() previously worked with rotated bounding boxes. If I remove flatten to execute the code, the error is gone but I am getting wrong bounding boxes like this--

image description Please give some ideas to solve this issue.