#include <opencv2\opencv.hpp>
int main()
{
cv::VideoCapture capture(0);
cv::namedWindow("camera", CV_WINDOW_AUTOSIZE);
cv::Mat tmpVideo;
cv::Mat gray;
IplImage* video, *image;
CvPoint2D32f* corners = new CvPoint2D32f;
int num = 100;
while (true)
{
/*
귀찮지만 cvGoodFeaturesToTrack 는 IplImage형 변수에서만 작동되므로 형변환을 거쳐야 했다.
ㅠㅠㅠㅠㅠㅠㅠㅠㅠ
*/
capture >> tmpVideo;
cv::cvtColor(tmpVideo, gray, CV_BGR2GRAY);
video = &IplImage(gray);
image = &IplImage(tmpVideo);
cvGoodFeaturesToTrack(video, NULL, NULL, corners, &num, 0.1, 5);
for (int i = 0; i < num; i++) {
cvCircle(image, cvPointFrom32f(corners[i]),3, CV_RGB(0,255,255), 2);
}
cvShowImage("camera", image);
if (cv::waitKey(30) == 27) {
break;
cvDestroyAllWindows();
cvReleaseImage(&video);
}
}
cv::destroyAllWindows();
return 0;
}