1 | #ifdef _OPENCV21
|
2 | #include <cv.h>
|
3 | #include <highgui.h>
|
4 | #else
|
5 |
|
6 | #include <opencv2/core/core_c.h>
|
7 | #include <opencv2/imgproc/imgproc_c.h>
|
8 | #include <opencv2/highgui/highgui_c.h>
|
9 | #endif
|
10 |
|
11 | #include <stdio.h>
|
12 |
|
13 | int main(int argc, char* argv[])
|
14 | {
|
15 |
|
16 |
|
17 | IplImage *frame;
|
18 | CvCapture *capture;
|
19 | CvSize size;
|
20 |
|
21 | capture = cvCaptureFromCAM(0);
|
22 |
|
23 | cvSetCaptureProperty(capture,CV_CAP_PROP_FPS, 15);
|
24 | cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,640);
|
25 | cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,480 );
|
26 | frame = cvQueryFrame(capture);
|
27 | cvShowImage("correct frame 640*480",frame);
|
28 | size = cvGetSize(frame);
|
29 | printf("width: %d, height: %d\n", size.width, size.height);
|
30 |
|
31 | cvSetCaptureProperty(capture,CV_CAP_PROP_FPS, 15);
|
32 | cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,320);
|
33 | cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,240 );
|
34 | frame = cvQueryFrame(capture);
|
35 | cvShowImage("correct frame 320*240",frame);
|
36 | size = cvGetSize(frame);
|
37 | printf("width: %d, height: %d\n", size.width, size.height);
|
38 |
|
39 | cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,320);
|
40 | cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,240 );
|
41 | cvSetCaptureProperty(capture,CV_CAP_PROP_FPS, 15);
|
42 | frame = cvQueryFrame(capture);
|
43 | size = cvGetSize(frame);
|
44 | printf("width: %d, height: %d\n", size.width, size.height);
|
45 |
|
46 | cvShowImage("fault: frame 640*480",frame);
|
47 | cvWaitKey(0);
|
48 |
|
49 | cvReleaseCapture(&capture);
|
50 | }
|
51 |
|