opencv 霍夫圆变换识别网球 通过滑动条来修改参数

//2011/06/14  
#include "cv.h"  
#include "highgui.h"  
#include   
#include"iostream"
using namespace std ;
IplImage* src = NULL  ;  
IplImage* dst = NULL ; 
IplImage* img = NULL ; 
IplImage* img1 = NULL ; 
IplImage* img2 = NULL ; 
static const char* wnd_name = "canny" ;  
static const char* file_name = "lena.jpg" ;  
static const char* trackbar_name = "threshold" ;  
void on_track( int pos )  
{ 


	 img1 = cvCreateImage (cvGetSize(img), IPL_DEPTH_8U, 1); 
	 img2 = cvCreateImage (cvGetSize(img), IPL_DEPTH_8U, 3);
	if (img->nChannels == 1)
		{
		img1= cvCloneImage (img);
		}
		else
		{
		cvCvtColor (img, img1, CV_RGB2GRAY); //转áa为a单죤通a?§道쨤
		}
	    CvMemStorage* storage=cvCreateMemStorage(0);
		CvSeq* circle = 0;

		cvSmooth( img1, img1, CV_GAUSSIAN, 5, 5 );
	 //   cvSmooth( img1, img1, CV_GAUSSIAN, 5, 5 ); 
	    cvSmooth( img1, img1, CV_GAUSSIAN, 5, 5 ); 
		circle = cvHoughCircles( 
		img1,
		storage,
		CV_HOUGH_GRADIENT,
		1, 
		32,
		50,
		pos,
		0,
		0
		);

		cvCvtColor (img1, img2, CV_GRAY2RGB); //转áa为a3通a?§道쨤



		for( int i = 0; i < circle->total; i++ )
		{
		float* p = ( float* )cvGetSeqElem( circle, i );

		CvPoint pt = cvPoint( cvRound( p[0] ), cvRound( p[1] ) ); //圆2心?坐á?标à¨o(ê?§p(ê?§0)ê?,ê?p(ê?§1)ê?)ê?
		cout<

你可能感兴趣的:(c++)