-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayWithConsoleApp.cpp
More file actions
39 lines (37 loc) · 884 Bytes
/
PlayWithConsoleApp.cpp
File metadata and controls
39 lines (37 loc) · 884 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
33
34
35
36
37
38
39
#include "stdafx.h"
#include "opencv2\highgui\highgui.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
VideoCapture cap(1); // open the video camera no. 0
if (!cap.isOpened()) // if not success, exit program
{
cout << "Cannot open the video cam" << endl;
system("pause");
return -1;
}
double dwidth= cap.get(CV_CAP_PROP_FRAME_WIDTH);
double dheight= cap.get(CV_CAP_PROP_FRAME_HEIGHT);
cout<<"Frame size:"<<dwidth<<"x"<<dheight<<endl;
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE);
system("pause");
while (1)
{
Mat frame;
bool bSuccess=cap.read(frame);
if(!bSuccess)
{
cout<<"cannot read a frame from video stream"<<endl;
break;
}
imshow("MyVideo",frame);
if(waitKey(30)==27)
{
cout<<"esc key is pressed by user"<<endl;
break;
}
}
return 0;
}