Last active
August 29, 2015 13:58
-
-
Save TheB1ackSheep/9958652 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 "opencv2/imgproc/imgproc.hpp" | |
#include "opencv2/highgui/highgui.hpp" | |
#include <stdio.h> | |
#include <iostream> | |
using namespace cv; | |
using namespace std; | |
int main(void){ | |
VideoCapture cap(0); | |
if (!cap.isOpened()) | |
{ | |
cout << "Cannot capture your webcam" << endl; | |
return -1; | |
} | |
namedWindow("Webcam", CV_WINDOW_AUTOSIZE); | |
while (1) | |
{ | |
Mat frame; | |
bool bSuccess = cap.read(frame); | |
if (!bSuccess){ | |
cout << "Cannot read the frame from your cam" << endl; | |
break; | |
} | |
imshow("Webcam", frame); | |
if (waitKey(30) == 27) //wait for 'esc' key press for 30 ms. If 'esc' key is pressed, break loop | |
{ | |
cout << "esc key is pressed by user" << endl; | |
break; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment