An example using the fitEllipse technique
#include <iostream>
using namespace cv;
using namespace std;
int sliderPos = 70;
void processImage(int, void*);
int main(
int argc,
char** argv )
{
const char* filename = argc == 2 ? argv[1] : (char*)"../data/stuff.jpg";
if( image.empty() )
{
cout << "Couldn't open image " << filename << "\nUsage: fitellipse <image_name>\n";
return 0;
}
createTrackbar(
"threshold",
"result", &sliderPos, 255, processImage );
processImage(0, 0);
return 0;
}
void processImage(int , void*)
{
vector<vector<Point> > contours;
Mat bimage = image >= sliderPos;
for(
size_t i = 0;
i < contours.size();
i++)
{
size_t count = contours[
i].size();
if( count < 6 )
continue;
continue;
ellipse(cimage, box.
center, box.
size*0.5f, box.
angle, 0, 360,
Scalar(0,255,255), 1,
LINE_AA);
for( int j = 0; j < 4; j++ )
}
}