Skip to content

Python: handle errors in Rect conversions#19380

Merged
opencv-pushbot merged 1 commit intoopencv:masterfrom
alalek:python_fix_rect_conversion
Jan 24, 2021
Merged

Python: handle errors in Rect conversions#19380
opencv-pushbot merged 1 commit intoopencv:masterfrom
alalek:python_fix_rect_conversion

Conversation

@alalek
Copy link
Copy Markdown
Member

@alalek alalek commented Jan 23, 2021

Minimal hotfix for test_overload_resolution() tests.

relates #14780


Tests with Rect conversions should be added in a separate PR (to 3.4 branch). Probably after #19344 to avoid conflicts

cv.rectangle(frame, np.array(box), (0, 255, 0))
cv.rectangle(frame, tuple(box), (0, 255, 0))
cv.rectangle(frame, list(box), (0, 255, 0))
# FIXIT never properly work: cv.rectangle(frame, list(box), (0, 255, 0))
Copy link
Copy Markdown
Member Author

@alalek alalek Jan 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabled, because conversion to Rect is never worked properly here (result of Rect(0,0,0,0) or garbage due to index out of range access).

(conversion should be rewritten, starting form "3.4" branch with related tests - out of scope for this hotfix)

with self.assertRaises((cv.error, Exception), msg=no_exception_msg) as cm:
cv.utils.testOverloadResolution(*args, **kwargs)
res = cv.utils.testOverloadResolution(*args, **kwargs)
self.fail("Unexpected result for {}: '{}'".format(msg, res))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertRaises should mark the test as failed with a proper no_exception_msg if exception doesn't occur.
What is the purpose of this line?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dump result of the call.

{
std::vector<int> value(4);
pyopencvVecConverter<int>::to(obj, value, info);
if (!pyopencvVecConverter<int>::to(obj, value, info))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this part wont be needed after #19344 merge, because it handles all Python sequence in a common way.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm aware of this patch and agree that implementation will be replaced.

@alalek
Copy link
Copy Markdown
Member Author

alalek commented Jan 24, 2021

👍

@opencv-pushbot opencv-pushbot merged commit 8e5e1b6 into opencv:master Jan 24, 2021
@alalek alalek mentioned this pull request Apr 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants