tensorflow / models

Models and examples built with TensorFlow
Other
76.97k stars 45.79k forks source link

Is the area formula for bouding box used in the tfrecord code correct? #11024

Open fabihabushra opened 1 year ago

fabihabushra commented 1 year ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

1. The entire URL of the file you are using

research/object_detection/dataset_tools/context_rcnn/create_cococameratraps_tfexample_main.py

2. Describe the bug

" for object_annotations in annotations: if 'bbox' in object_annotations and self._keep_bboxes: (x, y, width, height) = tuple(object_annotations['bbox']) if width <= 0 or height <= 0: num_annotations_skipped += 1 print(f"Skipping annotation for image ID: {image_id} - Invalid bounding box dimensions.") continue if x + width > image_width or y + height > image_height: num_annotations_skipped += 1 print(f"Skipping annotation for image ID: {image_id} - Bounding box exceeds image boundaries.") continue xmin.append(float(x) / image_width) xmax.append(float(x + width) / image_width) ymin.append(float(y) / image_height) ymax.append(float(y + height) / image_height) if 'area' in object_annotations: area.append(object_annotations['area']) else:

approximate area using l*w/2

        area.append(width*height/2.0)

"

Inside the code, I found that the formula of area for the bounding box being used is "widthheight/2.0". Since the bounding box is a rectangle, I am wondering why is the original formula of an area of a rectangle(area = widthheight) is being divided by 2? Is it correct?

Petros626 commented 1 year ago

from where you get the "original formula" for the bounding boxes?