Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

ellipse_ver.png

see image attached.

the code:

std::string filename = "ellipse_ver.png"; cv::Mat image = cv::imread(filename, CV_LOAD_IMAGE_GRAYSCALE); if (image.empty()){ return -1; }

std::vector<std::vector<cv::point>> contours; cv::findContours(image.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); cv::RotatedRect r = cv::fitEllipse(contours.at(0));

ellipse_ver.png

see image attached.

the code:

std::string filename = "ellipse_ver.png"; "ellipse_ver.png";

cv::Mat image = cv::imread(filename, CV_LOAD_IMAGE_GRAYSCALE); CV_LOAD_IMAGE_GRAYSCALE);

if (image.empty()){
      return -1;
    }
}

std::vector<std::vector<cv::point>> contours;

std::vector<std::vector<cv::point>> contours; cv::findContours(image.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); CV_CHAIN_APPROX_NONE);

cv::RotatedRect r = cv::fitEllipse(contours.at(0));

ellipse_ver.png

see image attached.

the code:

std::string filename = "ellipse_ver.png"; 

cv::Mat image = cv::imread(filename, CV_LOAD_IMAGE_GRAYSCALE);

CV_LOAD_IMAGE_GRAYSCALE);
if (image.empty()){

    return -1;

}

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

cv::findContours(image.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);

cv::RotatedRect r = cv::fitEllipse(contours.at(0));

std::vector<std::vector<cv::point>> contours;

cv::findContours(image.clone(), contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE);

cv::RotatedRect r = cv::fitEllipse(contours.at(0));