Skip to content

Conversation

@dongminlee94
Copy link
Contributor

Summary

This pull request resolves the parsing error that occurs when OpenCV’s cv2.boxPoints() receives PyTorch tensor scalars instead of Python floats. By explicitly converting the tensor values (x, y, w, h, theta) to float, we ensure that the function receives the correct data type for constructing a valid rotated rectangle, preventing the Can't parse 'box' center point. Sequence item with index 0 has a wrong type error.

Changes

In the gen_bbx() function, replaced the direct usage of PyTorch tensors with explicit float casts.

Specifically, changed:

box = ((x, y), (w, h), theta)

to

box = ((float(x), float(y)), (float(w), float(h)), float(theta))

This ensures that each value is a Python float before being passed to cv2.boxPoints().

Benefits

  • Eliminates the Can't parse 'box' center point error by providing valid (center, size, angle) inputs to cv2.boxPoints().
  • Allows the shadow generation (and any other functionality relying on gen_bbx()) to proceed without runtime failures.
  • Improves compatibility between PyTorch and OpenCV in scenarios where tensor scalars must be interpreted as floats.

Testing

  • Verified by running the existing test_shadow_generation.py within libcom/tests/.
  • After applying the float conversion, the error no longer occurs, and the shadow generation results are produced successfully.

@YujieOuO YujieOuO merged commit edcdbcc into bcmi:main Mar 21, 2025
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants