int _tmain(int argc, _TCHAR* argv[]) {
IplImage *image = cvLoadImage("LenaGr.jpg", 0);
CvMemStorage *storage = cvCreateMemStorage(0);
cvSmooth(image, image, CV_GAUSSIAN, 5, 5);
CvSeq *results = cvHoughCircles(
image,
storage,
CV_HOUGH_GRADIENT,
2,
image -> width / 10
);
for(int i = 0; i < results -> total; i++) {
float *p = (float *) cvGetSeqElem(results, i);
CvPoint pt = cvPoint(cvRound(p[0]), cvRound(p[1]));
cvCircle(
image,
pt,
cvRound(p[2]),
CV_RGB(0xff, 0xff, 0xff)
);
}
cvNamedWindow("Test", CV_WINDOW_AUTOSIZE);
cvShowImage("Test", image);
cvWaitKey(0);
cvReleaseImage(&image);
cvDestroyWindow("Test");
return 0;
}
cvHoughCircles
最新推荐文章于 2021-12-04 21:39:48 发布