I am trying to detect ellipse in an image using opencv. I find the contours which include ellipse and also some other ones.
Any suggestions that how can I check which contours are ellipse?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
if I understand you correctly, you have detected contours some of them are ellipses and some are not and you want to be able to decide which ones are. Is it right?
If yes, I would suggest to use
cv::fitEllipse(). The doc says that it fits an ellipse to a vector of points so that R-squared is minimal. Unfortunately, the function does not return explicitly the R-squared value. You can maybe implement it yourself…As a workaround, you can also use a something such as:
To compare them you can use moments (cf.
cv::moments()andcv::matchShapes()).I do not think you need invariant moments here, though.
Alternatively, you can draw C and E find what proportion of there surface overlap.
Good luck,