资源描述:
《opencv 椭圆检测识别并画出轮廓》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、*#include"stdafx.h"#include"cv.h"#include"highgui.h"usingnamespacecv;usingnamespacestd;//标示符的可见范围CvPoint2D32fGetCPoint(IplImage*imageFg,intmaxX);voidFitEllipseBlob(IplImage*imageFg);intmain(intargc,char**argv){IplImage*pImg;//声明IplImage指针//载入图像pImg=cvLoadImage("C:\Users\BBDesktop\b
2、ec\OPENCV椭圆拟合定位椭圆中心点以及重心法定位程序\OPENCV椭圆拟合定位椭圆中心点以及重心法定位程序\特征中心点提取误差分析\image.bmp",1);//[[此处的argc==2是否需要改成argc==1?我改了之后才能运行成功。求大牛解惑]]//wmzzzz:在"属性"
3、"debug"
4、里的commandarguments里加入参数(一个路径:要打开的文件路径)这时argc==2就合理了...可以试试多加几个intpointX=0;for(inti=0;i<19;i++){pointX=60*i+30;cvEllipse(pImg,cvPo
5、int(pointX,80),cvSize(19,20),-200,0,360,CV_RGB(255,255,255),-1,CV_AA,0);}IplImage*m_imageGray=cvCreateImage(cvSize(pImg->width,pImg->height),IPL_DEPTH_8U,1);IplImage*m_imageBw=cvCreateImage(cvSize(pImg->width,pImg->height),IPL_DEPTH_8U,1);cvCvtColor(pImg,m_imageGray,CV_RGB2GRAY);cvThre
6、shold(m_imageGray,m_imageBw,128,255,CV_THRESH_BINARY);CvPoint2D32fpointXX;floatXXX,YYY;for(inti=0;i<19;i++){pointX=60*i+60;pointXX=GetCPoint(m_imageBw,pointX);XXX=pointXX.x;YYY=pointXX.y;cout<7、mageBw);cvNamedWindow("Image",1);//创建窗口cvShowImage("Image",m_imageBw);//显示图像cvSaveImage("image.bmp",pImg);cvWaitKey(0);//等待按键cvDestroyWindow("Image");//销毁窗口cvReleaseImage(&pImg);//释放图像return0;}CvPoint2D32fGetCPoint(IplImage*imageFg,intmaxX){CvPoint2D32fpoint;doubleXsum=0,Ysum=0,Sum=0;C
8、vScalarValue;for(intj=0;jheight;j++){for(inti=maxX-60;i9、t(200,300),cvSize(10,11),-202.55482,0,360,CV_RGB(255,0,0),1,CV_AA,0);return;CvMemStorage*stor;CvSeq*cont;CvBox2D32f*box;CvPoint*PointArray;CvPoint2D32f*PointArray2D32f;stor=cvCreateMemStorage(0);cont=cvCreateSeq(CV_SEQ_ELTYPE_POINT,sizeof(CvSeq),sizeof(CvPoint),stor);/////*cvSetImage