forked from kcwongjoe/directshow_camera
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheg3_camera_looper.cpp
More file actions
45 lines (34 loc) · 1.29 KB
/
eg3_camera_looper.cpp
File metadata and controls
45 lines (34 loc) · 1.29 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
#include "eg3_camera_looper.h"
#include <uvc_camera_looper.h>
#include <iostream>
using namespace DirectShowCamera;
void eg3_camera_looper()
{
// Create a looper
UVCCameraLooper cameraLooper = UVCCameraLooper();
// Open the first camera
std::cout << "Open the first camera..." << std::endl;
std::vector<CameraDevice> cameraDeivceList = cameraLooper.getCamera()->getCameras();
cameraLooper.getCamera()->open(cameraDeivceList[0]);
// Set a process to handle the captured image
cameraLooper.setCapturedProcess(
[](cv::Mat image)
{
std::cout << "Get a new image(" + std::to_string(image.cols) + " x " + std::to_string(image.rows) + ")" << std::endl;
}
);
// Start looper to capture image continously
std::cout << "Start looper..." << std::endl;
cameraLooper.start();
// 1 second
std::this_thread::sleep_for(std::chrono::seconds(1));
// You can save image automatically
std::cout << "Start to save images..." << std::endl;
cameraLooper.enableSaveImage(true);
std::this_thread::sleep_for(std::chrono::milliseconds(400));
std::cout << "Stop to save images..." << std::endl;
cameraLooper.enableSaveImage(false);
// Stop looper
std::cout << "Stop looper..." << std::endl;
cameraLooper.stop();
}