find and drawContours doc
This commit is contained in:
parent
85f301ab9f
commit
1f9171d10a
@ -1,9 +1,21 @@
|
|||||||
#include "cv.h"
|
#include "cv.h"
|
||||||
#include "highgui.h"
|
#include "highgui.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
|
|
||||||
|
void help()
|
||||||
|
{
|
||||||
|
cout
|
||||||
|
<< "This program illustrates the use of findContours and drawContours\n"
|
||||||
|
<< "The original image is put up along with the image of drawn contours\n"
|
||||||
|
<< "Usage:\n"
|
||||||
|
<< "./contours2\n"
|
||||||
|
<< "\nA trackbar is put up which controls the contour level from -3 to 3\n"
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
const int w = 500;
|
const int w = 500;
|
||||||
int levels = 3;
|
int levels = 3;
|
||||||
|
|
||||||
@ -20,10 +32,15 @@ void on_trackbar(int, void*)
|
|||||||
imshow("contours", cnt_img);
|
imshow("contours", cnt_img);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int, char** )
|
int main( int argc, char** argv)
|
||||||
{
|
{
|
||||||
Mat img = Mat::zeros(w, w, CV_8UC1);
|
Mat img = Mat::zeros(w, w, CV_8UC1);
|
||||||
|
if(argc > 1)
|
||||||
|
{
|
||||||
|
help();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
//Draw 6 faces
|
||||||
for( int i = 0; i < 6; i++ )
|
for( int i = 0; i < 6; i++ )
|
||||||
{
|
{
|
||||||
int dx = (i%2)*250 - 30;
|
int dx = (i%2)*250 - 30;
|
||||||
@ -55,10 +72,10 @@ int main( int, char** )
|
|||||||
ellipse( img, Point(dx+27, dy+100), Size(20,35), 0, 0, 360, white, -1, 8, 0 );
|
ellipse( img, Point(dx+27, dy+100), Size(20,35), 0, 0, 360, white, -1, 8, 0 );
|
||||||
ellipse( img, Point(dx+273, dy+100), Size(20,35), 0, 0, 360, white, -1, 8, 0 );
|
ellipse( img, Point(dx+273, dy+100), Size(20,35), 0, 0, 360, white, -1, 8, 0 );
|
||||||
}
|
}
|
||||||
|
//show the faces
|
||||||
namedWindow( "image", 1 );
|
namedWindow( "image", 1 );
|
||||||
imshow( "image", img );
|
imshow( "image", img );
|
||||||
|
//Extract the contours so that
|
||||||
vector<vector<Point> > contours0;
|
vector<vector<Point> > contours0;
|
||||||
findContours( img, contours0, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE);
|
findContours( img, contours0, hierarchy, RETR_TREE, CHAIN_APPROX_SIMPLE);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user