-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcamera-viewer.cpp
More file actions
54 lines (40 loc) · 1.19 KB
/
camera-viewer.cpp
File metadata and controls
54 lines (40 loc) · 1.19 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "window.h"
#include <QApplication>
// Main program
int main(int argc, char *argv[])
{
if (argc < 2)
{
fprintf(stderr, "Usage: %s <video dev #>\n", argv[0]);
return 0;
}
QApplication app(argc, argv);
// Create camera
Camera camera;
// Create the window
Window window;
// Show the window
window.show();
// Connect the camera to the window
camera.registerFrameCallback([&](const cv::Mat &m)
{ window.updateImage(m); });
OpenCVparameters openCVparameters;
openCVparameters.deviceID = atoi(argv[1]);
openCVparameters.framerate = 30;
// Start the camera
openCVparameters = camera.start(openCVparameters);
if ((0 == openCVparameters.height) || (0 == openCVparameters.width))
{
fprintf(stderr, "Capture device has frame size of zero. Exiting.\n");
return -1;
}
fprintf(stderr, "Resolution: %d x %d\n", openCVparameters.width, openCVparameters.height);
fprintf(stderr, "FOURCC:");
for (long unsigned int i = 0; i < sizeof(openCVparameters.fourcc); i++)
fprintf(stderr, "%c", ((char *)(&openCVparameters.fourcc))[i]);
fprintf(stderr, "\n");
// Execute the application. This is blocking till the user closes it.
int r = app.exec();
camera.stop();
return r;
}