Optimize&Fix fitEllipse sample#23356
Merged
asmorkalov merged 1 commit intoopencv:3.4from Mar 17, 2023
Merged
Conversation
mshabunin
reviewed
Mar 14, 2023
Contributor
mshabunin
left a comment
There was a problem hiding this comment.
BTW, it would be cool to process key strokes and toggle active algorithms when e.g. 1, 2 and 3 keys have been pressed.
samples/cpp/fitellipse.cpp
Outdated
| if( MAX(box.size.width, box.size.height) > MIN(box.size.width, box.size.height)*30 || | ||
| MAX(box.size.width, box.size.height) <= 0 || | ||
| MIN(box.size.width, box.size.height) <= 0){continue;}; | ||
| //size.height >= size.width awalys,only if the pts are on a line or at the same point,size.width=0 |
Contributor
There was a problem hiding this comment.
size.height >= size.width awalys
Is this behavior built into fitEllipse?
Contributor
Author
There was a problem hiding this comment.
if( box.size.width > box.size.height )
{
float tmp;
CV_SWAP( box.size.width, box.size.height, tmp );
box.angle = (float)(fmod((90 + theta*180/CV_PI),180.0)) ;
}Yes,in the function of fitEllipseDirect、fitEllipseNoDirect、fitEllipseAMS include above code.
https://github.com/opencv/opencv/blob/4.x/modules/imgproc/src/shapedescr.cpp
Contributor
Author
That's a good idea. |
Optimize&Fix fitEllipse sample
a3c18af to
68e2df5
Compare
mshabunin
approved these changes
Mar 16, 2023
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1). At least 5 points can fit an ellipse
2). The result of fitEllipse、 fitEllipseAMS、fitEllipseDirect maybe different,I think it's better to draw the different result,rather than "continue".
3). Need to check the size of boxAMS/boxDirect ,not the size of box,after fitEllipseAMS、fitEllipseDirect.
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.