-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadFromCamera
More file actions
32 lines (31 loc) · 817 Bytes
/
Copy pathReadFromCamera
File metadata and controls
32 lines (31 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// code to read from camera
//#include "opencv2/stdafx/stdafx.h"
#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>
#ifdef _EiC
#define WIN32
#endif
char path[50];
int main ( int argc, const char* argv[] ){
CvCapture* capture = cvCaptureFromCAM(0);
IplImage* image = 0;
cvNamedWindow("Window");
int count = 1;
while (true)
{
image = cvQueryFrame(capture);
cvShowImage("Window", image);
int ch = cvWaitKey(1);
if(ch == 115){
sprintf(path,"d:/something/captured%d.bmp",count++);
cvSaveImage(path,image,0);
}
if(ch == 27) break;
}
cvDestroyWindow("Window");
cvReleaseCapture(&capture);
return 0;
}