Created
October 10, 2010 12:52
-
-
Save shihongzhi/619216 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "highgui.h" | |
#include "cv.h" | |
#include <stdio.h> | |
#define MAX_CORNERS 50 | |
int capture_data() | |
{ | |
CvCapture* capture; | |
IplImage* frame; | |
IplImage* gray; | |
IplImage* eigImage=NULL; | |
IplImage* tempImage=NULL; | |
CvPoint2D32f corners[MAX_CORNERS]={0}; | |
int corner_count=MAX_CORNERS,i; | |
char c; | |
capture=cvCreateCameraCapture(0); | |
if(!capture) | |
return -1; | |
cvNamedWindow("capture_data",CV_WINDOW_AUTOSIZE); | |
while(1) | |
{ | |
frame=cvQueryFrame(capture); | |
if(!frame) break; | |
gray=cvCreateImage( cvGetSize(frame), IPL_DEPTH_8U, 1 );; | |
eigImage=cvCreateImage( cvGetSize(frame), IPL_DEPTH_32F, 1 ); | |
tempImage=cvCreateImage( cvGetSize(frame), IPL_DEPTH_32F, 1 ); | |
cvCvtColor(frame,gray,CV_BGR2GRAY); | |
cvGoodFeaturesToTrack(gray,eigImage,tempImage,corners,&corner_count,0.01f,2.0,0,3,0,0.04f); | |
for(i=0;i<corner_count;i++) | |
cvRectangle(frame,cvPoint(corners[i].x-2,corners[i].y-2),cvPoint(corners[i].x+2,corners[i].y+2),cvScalar(255,0,0,0),1,8,0); | |
cvShowImage("capture_data",frame); | |
c=cvWaitKey(33); | |
if(c==27) break; | |
} | |
return 0; | |
} | |
int main(int argc,char** argv) | |
{ | |
if(capture_data()==-1) | |
printf("load camera fail!"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
注意cvGoodFeaturesToTrack这函数的参数,尤其是corner_count