find contour coordinates
来源:互联网 发布:倒计时小软件 编辑:程序博客网 时间:2024/05/21 08:30
<a target=_blank href="http://blog.csdn.net/augusdi/article/details/9000276">点击打开链接</a>
#include <cv.h>#include <cxcore.h>#include <highgui.h>#include <iostream>#include <stdio.h>#pragma comment(lib, "cv.lib")#pragma comment(lib, "cxcore.lib")#pragma comment(lib, "highgui.lib")int main( int argc, char** argv ){//声明IplImage指针IplImage* pImg = NULL; IplImage* pContourImg = NULL;CvMemStorage * storage = cvCreateMemStorage(0);CvSeq * contour = 0;int mode = CV_RETR_EXTERNAL;// CV_RETR_EXTERNALunsigned th=0;if( argc == 3)if(strcmp(argv[2], "all") == 0)mode = CV_RETR_CCOMP; //内外轮廓都检测 //创建窗口cvNamedWindow("src", 1);cvNamedWindow("contour",1);//载入图像,强制转化为Grayif( argc >= 2 && (pImg = cvLoadImage( argv[1], 0)) != 0 ){cvShowImage( "src", pImg );//为轮廓显示图像申请空间//3通道图像,以便用彩色显示pContourImg = cvCreateImage(cvGetSize(pImg),IPL_DEPTH_8U,3);//copy source image and convert it to BGR imagecvCvtColor(pImg, pContourImg, CV_GRAY2BGR);cvCanny(pImg, pImg, 50, 150, 5); int Num=cvFindContours( pImg, storage, &contour, sizeof(CvContour), mode, CV_CHAIN_APPROX_SIMPLE);std::cout<<"The number of Contours is:"<<Num<<std::endl;for(;contour!=0;contour=contour->h_next){printf("***************************************************\n");for(int i=0;i<contour->total;i++){CvPoint* p=(CvPoint*)cvGetSeqElem(contour,i);printf("p->x=%d,p->y=%d\n",p->x,p->y); }//将轮廓画出 cvDrawContours(pContourImg, contour, CV_RGB(255,0,0), CV_RGB(0, 255, 0), 0, 2, 0); }}else{//销毁窗口cvDestroyWindow( "src" );cvDestroyWindow( "contour" );cvReleaseMemStorage(&storage);return -1;}//显示图像cvShowImage( "contour", pContourImg );cvWaitKey(0);//销毁窗口cvDestroyWindow( "src" );cvDestroyWindow( "contour" );//释放图像cvReleaseImage( &pImg ); cvReleaseImage( &pContourImg ); cvReleaseMemStorage(&storage);return 0;}
0 0
- find contour coordinates
- Coordinates
- Contour
- contour
- Homogeneous Coordinates
- Homogeneous Coordinates
- Homogeneous Coordinates
- Contour Processing
- contour 轮廓
- contour count
- 轮廓的查找、表达、绘制、特性及匹配(How to Use Contour? Find, Component, Construct, Features & Match)
- 轮廓的查找、表达、绘制、特性及匹配(How to Use Contour? Find, Component, Construct, Features & Match)
- 轮廓的查找、表达、绘制、特性及匹配(How to Use Contour? Find, Component, Construct, Features & Match)
- 轮廓的查找、表达、绘制、特性及匹配(How to Use Contour? Find, Component, Construct, Features & Match)
- 轮廓的查找、表达、绘制、特性及匹配(How to Use Contour? Find, Component, Construct, Features & Match)
- 轮廓的查找、表达、绘制、特性及匹配(How to Use Contour? Find, Component, Construct, Features & Match)
- Transforming between image coordinates and world coordinates
- Transform screen coordinates to OpenGL coordinates
- 在VC中already defined in *.obj问题解决
- HTML5初窥6——SVG
- 【BZOJ3926】【Zjoi2015】诸神眷顾的幻想乡 广义后缀自动机
- head LiquidMetal instinct
- IBM在中国的发展加大开放的力度和范围
- find contour coordinates
- Java 集合fail-fast总结(通过ArrayList来说明fail-fast的原理、解决办法)
- android开发 - BroadcastReceiver 广播接收者
- java连接MySQL数据库
- File getAbsolutePath GetCanonicalPath
- 0000_0000_0000_0011 frame and bounce
- c++模板元编程五:switch/case语句编译时运行
- 2014年第五届蓝桥杯预赛部分题目—李白打酒
- codeingiter修改版本支持多module