C3_W1_Lab_3 draw_bounding_boxes_on_image function

Hello, I have a question on C3_W1_Lab 3. In this lab, there is a function:

draw_bounding_boxes_on_image(image, boxes, color, thickness, display_str_list).

My question is pertaining to the function call within this for loop:

draw_bounding_box_on_image(image, boxes[i, 1], boxes[i, 0], boxes[i, 3], boxes[i, 2], color[i], thickness, display_str_list[i])

draw_bounding_box_on_image() is defined with the following arguments:

draw_bounding_box_on_image(image, ymin, xmin, ymax, xmax, color, thickness, display_str, use_normalized_coordinates)

And boxes are defined as “a 2 dimensional numpy array of [N, 4]: (ymin, xmin, ymax, xmax)”.

It seems that if we are iterating over the N boxes, indexed with i, then
boxes[i, 0] = ymin,
boxes[i, 1] = xmin,
boxes[i, 2] = ymax,
boxes[i, 3] = xmax

Therefore, it seems that the for loop within draw_bounding_boxes_on_image should call:

draw_bounding_box_on_image(image, boxes[i, 0], boxes[i, 1], boxes[i, 2], boxes[i, 3], color[i], thickness, display_str_list[i]).

Can someone please tell me if my reasoning is correct, or if I am missing something? Any help would be greatly appreciated.

Thank you.

My understanding is that the numpy array of dimensions [N, 4] means for each number N representing the image index there are 4 other numbers in the second dimension representing the coordinates xmin, xmax, ymin, ymax.

Hello,

your concept of draw_bounding_box_on_image might be not fully correct. But as I cannot explain you more appropriately. I am tagging @ai_curious who has better understanding on YOLO algorithm. Let’s see what response he will give.

Thank you @ai_curious
DP

I just took a really quick look at it, and in the provided code where the labels are unpacked into the bounding box list the coordinates look like this…


bbox_list = [bbox[1] * factor_x ,
                 bbox[0] * factor_y,
                 bbox[3] * factor_x,
                 bbox[2] * factor_y]

That might be the source of your confusion about the order of the coordinates. Packing and unpacking of that list needs to by symmetric, right?