Skip to content

Instantly share code, notes, and snippets.

@ts-3156
Created July 1, 2011 02:26
Show Gist options
  • Save ts-3156/1057760 to your computer and use it in GitHub Desktop.
Save ts-3156/1057760 to your computer and use it in GitHub Desktop.
//
// OpenCVの新しいバージョンでの書き方
//
void Filter::cameraTest()
{
VideoCapture capture(0);
if(!capture.isOpened())
return;
namedWindow("camera");
while(1){
Mat frame;
capture >> frame;
imshow("camera", frame);
if(waitKey(33) == 27) // ESC
break;
}
}
//
// OpenCVの古いバージョンでの書き方
//
void Filter::cameraTest()
{
CvCapture* src;
IplImage* frame;
src = cvCaptureFromCAM(0);
if(src == NULL){
printf("カメラが見つからない");
cvWaitKey(0);
return;
}
cvNamedWindow("camera");
while(1){
frame = cvQueryFrame(src);
cvShowImage("camera", frame);
if(cvWaitKey(33) == 27) // ESC
break;
}
cvDestroyAllWindows();
cvReleaseCapture(&src);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment