forked from kcwongjoe/directshow_camera
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheg4_exposure_fusion.cpp
More file actions
57 lines (45 loc) · 1.6 KB
/
eg4_exposure_fusion.cpp
File metadata and controls
57 lines (45 loc) · 1.6 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
55
56
57
#include "eg4_exposure_fusion.h"
#include <uvc_camera.h>
#include <iostream>
using namespace DirectShowCamera;
void eg4_exposure_fusion()
{
// Get a empty camera
UVCCamera camera = UVCCamera();
// Open the first camera
std::cout << "Open the first camera..." << std::endl;
std::vector<CameraDevice> cameraDeivceList = camera.getCameras();
camera.open(cameraDeivceList[0]);
// Start Capture
std::cout << "Start capture..." << std::endl;
camera.startCapture();
// Wait for 1 second
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
// Capture a exposure fusion image
std::cout << "Start to capture in exposure fusion..." << std::endl;
cv::Mat frame = camera.exposureFusion();
cv::imwrite("image.jpg", frame);
// Processing exposure fusion image is time consumed. Use async mode to capture.
std::cout << "Use a async mode to capture image in exposure fusion..." << std::endl;
std::atomic<bool> calculatedFusion = false;
camera.exposureFusion(
[&calculatedFusion](cv::Mat fusionImage)
{
std::cout << "Captured in async mode." << std::endl;
cv::imwrite("image2.jpg", fusionImage);
// Set the finished flag as true
calculatedFusion = true;
}
);
// Waiting for processed
int i = 0;
while (!calculatedFusion.load())
{
std::cout << std::to_string(++i) + "s" << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
// Stop Capture
camera.stopCapture();
// Close the camera.
camera.close();
}