Sometimes a detection's bbox boundaries are so small that they round to a set of bbox boundaries with zero area (e.g., [400, 0, 500, 0]). When this happens, ADC crashes with the response ValueError: cannot write empty image as JPEG. This line is included in the traceback:
|
detection.save_cropped_image_data( |
|
source_image=image, |
|
base_path=user_data_path, |
|
) |
If we just validate that bbox_area is a positive value before trying to save it, we could skip saving when the bbox is empty. I replaced those lines above with this temporary patch on my own machine:
if area_pixels is not None and area_pixels > 0:
detection.save_cropped_image_data(
source_image=image,
base_path=user_data_path,
)
else:
logger.warning(
f"Detected object with bbox {detection.bbox} has area 0, skipping cropped image save."
)
However, I don't know how this will affect downstream operations like trying to display an expected cropped image that is not there.
Sometimes a detection's bbox boundaries are so small that they round to a set of bbox boundaries with zero area (e.g., [400, 0, 500, 0]). When this happens, ADC crashes with the response
ValueError: cannot write empty image as JPEG. This line is included in the traceback:ami-data-companion/trapdata/db/models/detections.py
Lines 379 to 382 in a33746a
If we just validate that
bbox_areais a positive value before trying to save it, we could skip saving when the bbox is empty. I replaced those lines above with this temporary patch on my own machine:However, I don't know how this will affect downstream operations like trying to display an expected cropped image that is not there.