forked from kcwongjoe/directshow_camera
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheg2_properties.cpp
More file actions
56 lines (43 loc) · 1.88 KB
/
eg2_properties.cpp
File metadata and controls
56 lines (43 loc) · 1.88 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
#include "eg2_properties.h"
#include <uvc_camera.h>
#include <iostream>
using namespace DirectShowCamera;
void eg2_properties()
{
// Get a empty camera
UVCCamera camera = UVCCamera();
// Get available camera list
std::cout << "Start to list the available cameras..." << std::endl;
std::vector<CameraDevice> cameraDeivceList = camera.getCameras();
for (int i = 0; i < cameraDeivceList.size(); i++) {
std::cout << cameraDeivceList[i] << std::endl;
}
// Get first support resolution in the first camera
std::vector <std::pair<int, int>> resolutions = cameraDeivceList[0].getResolutions();
std::cout << "Width: " + std::to_string(resolutions[0].first) + ", Height: " + std::to_string(resolutions[0].second) << std::endl;
// Open the first camera in the biggest resolution
std::cout << "Open the first camera..." << std::endl;
camera.open(cameraDeivceList[0],
resolutions[resolutions.size() - 1].first,
resolutions[resolutions.size() - 1].second
);
std::cout << "show DirectShow properties" << std::string(*camera.getDirectShowProperties()) << std::endl;
// Get exposure in second
double exposureTime = camera.getExposure();
if (exposureTime > 0.0)
{
std::cout << "Exposure: " + std::to_string(exposureTime) + "s" << std::endl;
// Set exposure as the largest value
std::vector<double> exposures = camera.getPossibleExposureValues();
camera.setExposure(exposures[exposures.size() - 1]);
std::cout << "Set exposure to " + std::to_string(exposures[exposures.size() - 1]) + "s" << std::endl;
}else
{
std::cout << "This device doesn't support exposure time" << std::endl;
}
// Reset all properties to default
std::cout << "Reset properties to default..." << std::endl;
camera.resetProperties();
// Close the camera.
camera.close();
}