-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathliblumix.h
135 lines (115 loc) · 3.43 KB
/
liblumix.h
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#pragma once
#include <iostream>
#include <vector>
#include <variant>
#include <fmt/core.h>
#include <optional>
#include <string>
#include <algorithm>
#include <thread>
#include <atomic>
#include <condition_variable>
#include <pugixml.hpp>
// only include if the environment is build
#if defined LIBLUMIX_BUILD || defined __INTELLISENSE__
#include <cpr/cpr.h>
#include "build/_deps/cppcodec-src/cppcodec/hex_lower.hpp"
#include <jpeglib.h>
#include <libraw/libraw.h>
#endif
namespace Lumix {
struct CameraData {
std::string cameraIp;
int apiVersion[2]; // [major, minor]
std::string cameraName;
std::string manufacturer;
std::string modelName;
std::string modelNumber;
std::string serialNumber;
std::string udn; // Universal Device Name
int firmwareVersion[2]; // [major, minor]
};
struct ImageData {
uint32_t id;
std::string title;
std::string date;
std::string filename;
std::vector<unsigned char> rawFileData;
std::vector<unsigned char> pixelBuffer;
int width;
int height;
int channels;
int bit_depth;
};
class Camera {
public:
Camera(std::string cameraIp, std::string nameForConnection);
~Camera();
CameraData cameraData;
bool TakePhoto();
bool TakePhoto(float duration);
bool DownloadLatestPhoto(ImageData& imageData);
bool GetRawPixelData(ImageData& imageData);
private:
enum CameraRequestMode {
SetSetting,
GetInfo,
GetSetting,
GetState,
GetContentInfo,
CameraCommand,
CameraControl,
StartStream
};
enum GetSettingRequestType {
PA,
// Ex_Tele_Conv,
TouchType
};
enum SetSettingRequestType {
DisplayName,
Focal, // Aperture
ISO,
Exposure,
ShutterSpeed,
Peaking,
Filter,
ColorMode,
FocusMode,
LightMettering,
VideoQuality
};
enum GetInfoRequestType {
Capability,
AllMenu,
CurrentMenu,
Lens
};
enum CameraCommandRequestType {
PlayMode,
AutoReviewUnlock,
MenuEntry,
VideoRecordStart,
VideoRecordStop,
};
enum CameraControlRequestType {
TouchTrace,
AssistDisplay,
ChangeDisplayMagnification,
Focus
};
using CameraRequestType = std::variant<GetSettingRequestType, SetSettingRequestType, GetInfoRequestType, CameraCommandRequestType, CameraControlRequestType>;
std::string sessionId;
// separate thread variables
std::unique_ptr<std::thread> getStateThread;
std::atomic<bool> getStateThreadRunning = false;
std::condition_variable getStateThreadCondition;
std::mutex getStateThreadMutex;
bool Connect(std::string cameraIp, std::string nameForConnection);
pugi::xml_node SendCameraCommand(CameraRequestMode mode, std::optional<CameraRequestType> type, std::vector<std::string> params);
bool GetPixelDataFromJPG(ImageData& imageData);
bool GetPixelDataFromRW2(ImageData& imageData);
// thread functions
void GetStateThread();
};
}