有思想的鱼

coding fish

载入一幅图片寻找角点


画出角点 输出图片 并打印出角点坐标

具体解释参考   我思故我在 博客

http://blog.csdn.net/superdont/article/details/6587523

#include "cv.h"
#include "highgui.h"
#include "stdio.h"
#include "iostream.h"

#define max_corners 80

int main( )
{
        IplImage *srcImage = 0, *grayImage = 0, *corners1 = 0, *corners2 = 0;


    int cornerCount=max_corners;
    CvPoint2D32f corners[max_corners];
    double qualityLevel;
    double minDistance;


     CvScalar color = CV_RGB(255,0,0);
    
    cvNamedWindow( "image", 0 ); 
   
    srcImage = cvLoadImage("Chess.bmp", 1);
    
    grayImage = cvCreateImage(cvGetSize(srcImage), IPL_DEPTH_8U, 1);
    
    cvCvtColor(srcImage, grayImage, CV_BGR2GRAY);
    
    corners1= cvCreateImage(cvGetSize(srcImage), IPL_DEPTH_32F, 1);
    corners2= cvCreateImage(cvGetSize(srcImage),IPL_DEPTH_32F, 1);
    
    cvGoodFeaturesToTrack (grayImage, corners1, corners2, corners,
        &cornerCount, 0.05, 5, 0);
    
    printf("num corners found: %d/n", cornerCount);
    
   
    if(cornerCount>0) 
    {
        for (int i=0; i<cornerCount; i++) 
        {
            cvCircle(srcImage, cvPoint((int)(corners[i].x), (int)(corners[i].y)), 6,
                color, 2, CV_AA, 0);
        }
    }
    
    cvShowImage( "image", srcImage );

 for (int j=0;j<cornerCount;j++)
 {
         cout<<corners[j].x;
     cout<<","<<corners[j].y<<endl;
 }
    
    cvReleaseImage(&srcImage);
    cvReleaseImage(&grayImage);
    cvReleaseImage(&corners1);
    cvReleaseImage(&corners2);
    
    cvWaitKey(0); 
    return 0;
}


阅读更多
文章标签: image
个人分类: OpenCV
想对作者说点什么? 我来说一句

画矩形(阵列)

2014年09月29日 47KB 下载

没有更多推荐了,返回首页

不良信息举报

载入一幅图片寻找角点

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭