diff --git a/mediapipe/calculators/tensor/image_to_tensor_utils.cc b/mediapipe/calculators/tensor/image_to_tensor_utils.cc index 6b3bf08cd..d1802f0be 100644 --- a/mediapipe/calculators/tensor/image_to_tensor_utils.cc +++ b/mediapipe/calculators/tensor/image_to_tensor_utils.cc @@ -24,7 +24,8 @@ namespace mediapipe { RotatedRect GetRoi(int input_width, int input_height, absl::optional norm_rect) { - if (norm_rect) { + + if (norm_rect && norm_rect->width() * input_width >= 2 && norm_rect->height() * input_height >= 2) { return {/*center_x=*/norm_rect->x_center() * input_width, /*center_y =*/norm_rect->y_center() * input_height, /*width =*/norm_rect->width() * input_width,