Is there any way to find an ellipse representation of a convex polygon stored as a set of vertex points in a vector?

asked 2014-08-29 11:12:47 -0500

Nate gravatar image

Greetings all,

I have a convex polygon stored as a set of vertex points within a vector. That is,

std::vector< cv::Point> polygon;

I want to find an ellipse representation of this polygon assuming it is solid. Does anyone know of an OpenCV function to find this? I tried using the following code I dug up from some documentation, but it results in an unlabeled unhandled runtime exception after attempting to run the fitEllipse() function.

// Doesn't work.
cv::Mat polyMat( polygon);
cv::RotatedRect ellipse= cv::fitEllipse( polyMat);

Does anyone know of some way to get an ellipse representation of a polygon?

Thanks for your time.

edit retag flag offensive close merge delete

Comments

In what sense does it not work?

stfn gravatar imagestfn ( 2014-08-29 19:07:51 -0500 )edit

The cv::fitEllipse(...) call results in a runtime exception.

Nate gravatar imageNate ( 2014-09-03 13:52:01 -0500 )edit