opencv例程之cvGoodFeaturesToTrack

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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值