Attention! This forum will be made read-only by Dec-20. Please migrate to Most of existing active users should've received invitation by e-mail.
Ask Your Question

ellipse() bug found!

asked 2014-02-13 02:03:35 -0500

mfeinstein gravatar image

updated 2014-02-13 02:04:55 -0500

I am using OpenCV 2.4.6, I cant test it in the most recent versions, so I thougt it will be just better to place it in here...I am sorry if this was already corrected in the most recent ones.

If I call ellipse() as:

ellipse(image, RotatedRect(Point2f(-78877.320,-79104.328),Size2f(1.0649987e-010f,3.1949962e-010f),0.0f), CV_RGB(255, 0, 0), 1, 8); // OpenCV Bug discovered!

being image a 640x480 image, my program crashes.

ellipse() calls EllipeseEx() who calls ellipse2Poly() who crashes.

ellipse() does:

Point center(cvRound(*(1 << XY_SHIFT)), cvRound(*(1 << XY_SHIFT)));

which makes center.x and center.y equals to INT_MIN. this way ellipse2Poly() crashes when it tries in it's last line to acessa an empty vector [0] position in:

if( pts.size() < 2 )

since for this case

if( pt != prevPt )

Is never != so the push_back() is never executed.

The code should be changed to

if( pts.size() < 2  && pts.size() > 0 )

So this way, the vector will be never acessed in case it's empty, crashing the program.

I am sorry to not submit this to the repository myself, I just can't upload that code right now.

edit retag flag offensive close merge delete


usually, you'd do a small test case, and go here

and ofc., ayou should check the src code for the 2.4 branch to see if it got fixed in the meantime

berak gravatar imageberak ( 2014-02-13 02:17:15 -0500 )edit

I know, I just cant do it right now...can you check this for me?

mfeinstein gravatar imagemfeinstein ( 2014-02-18 01:32:26 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-02-18 01:41:20 -0500

mfeinstein gravatar image

It was already fixed in the new version, sorry for this.

edit flag offensive delete link more


Well I cant accept my own answer, so if someone places one like this I will accept

mfeinstein gravatar imagemfeinstein ( 2014-02-18 01:42:15 -0500 )edit

anyway, nice, that you reported back ;)

berak gravatar imageberak ( 2014-02-18 08:15:38 -0500 )edit

Thanks, now there is just a weird behaviour I get in findContours() when I compile it as does a stackoverlow....I cant debug it since it's release, but removing findContours() makes the program run nicely...maybe its a bug in the dll? I wish I could foward this to someone more expert than me to analise it further....but I dont know anyone :/

mfeinstein gravatar imagemfeinstein ( 2014-02-18 21:25:38 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2014-02-13 02:03:35 -0500

Seen: 156 times

Last updated: Feb 18 '14