Created
August 5, 2018 10:38
-
-
Save santosh/7c52c59d61635d7fc667a1f23da101e6 to your computer and use it in GitHub Desktop.
Webcam feed in OpenCV. #ComputerVision
This file contains hidden or 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/opencv.hpp> | |
| #include <iostream> | |
| using namespace std; | |
| using namespace cv; | |
| int main(void) { | |
| // capture a video, for webcam, pass 0 instead of file path.. | |
| VideoCapture cap(0); | |
| if (!cap.isOpened()) { | |
| cout << "Error opening video stream or file" << endl; | |
| return -1; | |
| } | |
| while (1) { | |
| Mat frame; | |
| cap >> frame; | |
| if (frame.empty()) { | |
| break; | |
| } | |
| imshow("Frame", frame); | |
| char c=(char)waitKey(25); | |
| if (c==27) { | |
| break; | |
| } | |
| } | |
| cap.release(); | |
| destroyAllWindows(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment