关闭

载入一幅图片寻找角点

463人阅读 评论(0) 收藏 举报


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

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

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;
}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:62126次
    • 积分:734
    • 等级:
    • 排名:千里之外
    • 原创:11篇
    • 转载:13篇
    • 译文:0篇
    • 评论:14条
    文章分类
    文章存档
    最新评论