Skip to content

Commit

Permalink
Merge branch 'main' into feat/store-bounding-rect-as-detection-polygon
Browse files Browse the repository at this point in the history
  • Loading branch information
grzegorz-roboflow authored Jan 29, 2025
2 parents 5dca01c + 21f627e commit 88d649a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,14 @@ def run(
if obj_w_pixels > 0 and obj_h_pixels > 0:
obj_w_actual = obj_w_pixels * width_scale
obj_h_actual = obj_h_pixels * height_scale
dimensions.append({"width": obj_w_actual, "height": obj_h_actual})
dimensions.append(
{
"width": obj_w_actual,
"height": obj_h_actual,
"longer": max(obj_w_actual, obj_h_actual),
"shorter": min(obj_w_actual, obj_h_actual),
}
)
else:
dimensions.append(None)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ def test_size_measurement_block():
result = block.run(reference_predictions, object_predictions, reference_dimensions)

# then
expected_dimensions = [{"width": 5.0, "height": 5.0}, {"width": 5.0, "height": 5.0}]
expected_dimensions = [
{"width": 5.0, "height": 5.0, "longer": 5.0, "shorter": 5.0},
{"width": 5.0, "height": 5.0, "longer": 5.0, "shorter": 5.0},
]
assert result == {
OUTPUT_KEY: expected_dimensions
}, f"Expected {expected_dimensions}, but got {result}"
Expand Down Expand Up @@ -59,7 +62,10 @@ def test_size_measurement_block_with_mask():
result = block.run(reference_predictions, object_predictions, reference_dimensions)

# then
expected_dimensions = [{"width": 5.0, "height": 5.0}, {"width": 5.0, "height": 5.0}]
expected_dimensions = [
{"width": 5.0, "height": 5.0, "longer": 5.0, "shorter": 5.0},
{"width": 5.0, "height": 5.0, "longer": 5.0, "shorter": 5.0},
]
assert result == {
OUTPUT_KEY: expected_dimensions
}, f"Expected {expected_dimensions}, but got {result}"
Expand Down

0 comments on commit 88d649a

Please sign in to comment.