#include <iostream>
#include <stdio.h>
#include <stdlib.h>
int thresh = 100;
int max_thresh = 255;
void thresh_callback(int, void* );
int main( int, char** argv )
{
const char* source_window = "Source";
createTrackbar(
" Threshold:",
"Source", &thresh, max_thresh, thresh_callback );
thresh_callback( 0, 0 );
return(0);
}
void thresh_callback(int, void* )
{
vector<vector<Point> > contours;
vector<Vec4i> hierarchy;
vector<vector<Point> > contours_poly( contours.size() );
vector<Rect> boundRect( contours.size() );
vector<Point2f>center( contours.size() );
vector<float>radius( contours.size() );
for( size_t i = 0; i < contours.size(); i++ )
}
for( size_t i = 0; i< contours.size(); i++ )
{
Scalar color =
Scalar( rng.uniform(0, 255), rng.uniform(0,255), rng.uniform(0,255) );
drawContours( drawing, contours_poly, (
int)i, color, 1, 8, vector<Vec4i>(), 0,
Point() );
rectangle( drawing, boundRect[i].tl(), boundRect[i].br(), color, 2, 8, 0 );
circle( drawing, center[i], (
int)radius[i], color, 2, 8, 0 );
}
imshow(
"Contours", drawing );
}