您的位置:首页 > 运维架构

opencv例程之cvGoodFeaturesToTrack

2014-05-24 15:48 375 查看
//http://blog.csdn.net/moc062066
//chinamochen@gmail.com
//2014年5月24日
//

#include<cv.h>
#include<highgui.h>
#include<iostream>
#include<cxcore.h>
using namespace std ;
int main(int argc, char *argv[])
{

// Load a color image, and convert it into grayscale

IplImage* img = cvLoadImage("F:\\lena.jpg");

IplImage* img_gray = cvCreateImage(cvGetSize(img), 8, 1);
cvCvtColor(img, img_gray, CV_BGR2GRAY);

// Create temporary images required by cvGoodFeaturesToTrack
IplImage* img_temp = cvCreateImage(cvGetSize(img), 32, 1);
IplImage* img_eigen = cvCreateImage(cvGetSize(img), 32, 1);

// Create the array to store the points detected( <= 1000 )
int count = 1000;
CvPoint2D32f* corners = new CvPoint2D32f[count];

// Find corners
cvGoodFeaturesToTrack(img_gray, img_eigen, img_temp, corners, &count, 0.1, 10);

// Mark these corners on the original image
for(int i=0;i<count;i++)
{
cvLine(img, cvPoint(corners[i].x, corners[i].y), cvPoint(corners[i].x, corners[i].y), CV_RGB(255,0,0), 5);
}

// Display it
cvNamedWindow("img");
cvShowImage("img", img);

// Print the number of corners
printf("Detected Points : %d\n", count);

cvWaitKey(0);

return  0 ;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: