Created
November 15, 2012 19:24
-
-
Save nikhil9/4080630 to your computer and use it in GitHub Desktop.
Camera Access using Opencv
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 <iostream> | |
#include <cv.h> | |
#include <highgui.h> | |
using namespace std; | |
char key; | |
int main() | |
{ | |
cvNamedWindow("Camera_Output", 1); //Create window | |
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY); //Capture using any camera connected to your system | |
while(1){ //Create infinte loop for live streaming | |
IplImage* frame = cvQueryFrame(capture); //Create image frames from capture | |
cvShowImage("Camera_Output", frame); //Show image frames on created window | |
key = cvWaitKey(10); //Capture Keyboard stroke | |
if (char(key) == 27){ | |
break; //If you hit ESC key loop will break. | |
} | |
} | |
cvReleaseCapture(&capture); //Release capture. | |
cvDestroyWindow("Camera_Output"); //Destroy Window | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment