camera.cxx
9.8 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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#include <string>
#include <thread>
#include "uav_core.h"
#include "uav_logger.h"
#include "uav_platform.h"
#include "uav_sdk_app_info.h"
#include "uav_camera_manager.h"
#include "uav_positioning.h"
static void cameraManagerThreadFunc()
{
UAVCameraManager_Init();
//wait register success
if(false == wait_register_ready(100)){
LOG_ERROR("waitHandShakeRegister failed");
return;
}
int index = 2;
switch (index)
{
case 1:{
UAVCameraManager_StartShootPhoto();
std::this_thread::sleep_for(std::chrono::seconds(1));
UAVCameraManager_StartRecordVideo();
std::this_thread::sleep_for(std::chrono::seconds(10));
UAVCameraManager_StopRecordVideo();
}
break;
case 2:{
int ret = 0;
ret = UAVCameraManager_SetMode(UAV_CAMERA_MODE_SHOOT_PHOTO);
LOG_ERROR("camera SetMode: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetShootPhotoMode(UAV_CAMERA_SHOOT_PHOTO_MODE_SINGLE);
LOG_INFO("camera SetShootPhotoMode: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetPhotoBurstCount(UAV_CAMERA_BURST_COUNT_3);
LOG_INFO("camera SetPhotoBurstCount: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetPhotoAEBCount(UAV_CAMERA_MANAGER_PHOTO_AEB_COUNT_3);
LOG_INFO("camera SetPhotoAEBCount: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetPhotoTimeIntervalSettings(2);
LOG_INFO("camera SetPhotoTimeIntervalSettings: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetFocusMode(UAV_CAMERA_FOCUS_MODE_AUTO);
LOG_INFO("camera SetFocusMode: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
T_UAVCameraPointInScreen focusPosSetData;
focusPosSetData.focusX = 0.5f;
focusPosSetData.focusY = 0.5f;
ret = UAVCameraManager_SetFocusTarget(focusPosSetData);
LOG_INFO("camera SetFocusTarget: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetFocusRingValue(20);
LOG_INFO("camera SetFocusRingValue: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetExposureMode(UAV_CAMERA_MANAGER_EXPOSURE_MODE_PROGRAM_AUTO);
LOG_INFO("camera SetExposureMode: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetISO(UAV_CAMERA_MANAGER_ISO_400);
LOG_INFO("camera SetISO: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetAperture(UAV_CAMERA_MANAGER_APERTURE_F_2);
LOG_INFO("camera SetAperture: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetShutterSpeed(UAV_CAMERA_MANAGER_SHUTTER_SPEED_1);
LOG_INFO("camera SetShutterSpeed: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetExposureCompensation(UAV_CAMERA_MANAGER_EXPOSURE_COMPENSATION_P_1_0);
LOG_INFO("camera SetExposureCompensation: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetAELockEnabled(false);
LOG_INFO("camera SetAELockEnabled: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetPhotoFormat(UAV_CAMERA_MANAGER_PHOTO_STORAGE_FORMAT_JPEG);
LOG_INFO("camera SetPhotoFormat: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetVideoStorageFormat(UAV_CAMERA_MANAGER_VIDEO_STORAGE_FORMAT_MP4);
LOG_INFO("camera SetVideoStorageFormat: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetPhotoRatio(UAV_CAMERA_MANAGER_PHOTO_RATIO_4X3);
LOG_INFO("camera SetPhotoRatio: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetInfraredCameraGainMode(UAV_CAMERA_MANAGER_IR_GAIN_MODE_LOW);
LOG_INFO("camera SetInfraredCameraGainMode: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
ret = UAVCameraManager_SetMeteringMode(UAV_CAMERA_MANAGER_METERING_MODE_CENTRAL);
LOG_INFO("camera SetMeteringMode: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
T_UAVCameraManagerRangeList rangeList;
ret = UAVCameraManager_GetStreamSourceRange(
rangeList);
LOG_INFO("camera GetStreamSourceRange: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
T_UAVCameraManagerRangeList rangeList1;
ret = UAVCameraManager_GetPhotoFormatStorageRange(
rangeList1);
LOG_INFO("camera GetPhotoFormatStorageRange: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
T_UAVCameraManagerRangeList rangeList2;
ret = UAVCameraManager_GetVideoFormatRange(
rangeList2);
LOG_INFO("camera GetVideoFormatRange: {}", ret);
std::this_thread::sleep_for(std::chrono::seconds(1));
T_UAVPositioningEventInfo eventInfo[2];
T_UAVPositioningPositionInfo positionInfo[2];
eventInfo[0].eventIndex =0;
eventInfo[0].timestamp.year =2024;
eventInfo[0].timestamp.month =5;
eventInfo[0].timestamp.day =29;
eventInfo[0].timestamp.hour =9;
eventInfo[0].timestamp.minute =20;
eventInfo[0].timestamp.second =59;
eventInfo[0].timestamp.milliseconds =500;
eventInfo[1].eventIndex =1;
eventInfo[1].timestamp.year =2024;
eventInfo[1].timestamp.month =5;
eventInfo[1].timestamp.day =29;
eventInfo[1].timestamp.hour =9;
eventInfo[1].timestamp.minute =20;
eventInfo[1].timestamp.second =60;
eventInfo[1].timestamp.milliseconds =500;
UAV_Positioning_GetPositioning_Sync(2, (T_UAVPositioningEventInfo *)&eventInfo,(T_UAVPositioningPositionInfo *)&positionInfo);
}
break;
case 3:{
E_UAVCameraMode mode;
UAVCameraManager_GetMode(mode);
LOG_INFO("camera GetMode: {}", (int)mode);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraShootPhotoMode takePhotoMode;
UAVCameraManager_GetShootPhotoMode(takePhotoMode);
LOG_INFO("camera GetShootPhotoMode: {}", (int)takePhotoMode);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraBurstCount count;
UAVCameraManager_GetPhotoBurstCount(count);
LOG_INFO("camera GetPhotoBurstCount: {}", (int)count);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraManagerPhotoAEBCount aebCount;
UAVCameraManager_GetPhotoAEBCount(aebCount);
LOG_INFO("camera GetPhotoAEBCount: {}", (int)count);
std::this_thread::sleep_for(std::chrono::seconds(1));
uint32_t interval;
UAVCameraManager_GetPhotoTimeIntervalSettings(interval);
LOG_INFO("camera GetPhotoTimeIntervalSettings: {}", (int)interval);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraFocusMode focusMode;
UAVCameraManager_GetFocusMode(focusMode);
LOG_INFO("camera GetFocusMode: {}", (int)focusMode);
std::this_thread::sleep_for(std::chrono::seconds(1));
T_UAVCameraPointInScreen focusPosData;
UAVCameraManager_GetFocusTarget(focusPosData);
LOG_INFO("camera GetFocusTarget: {} {}", focusPosData.focusX,focusPosData.focusY);
std::this_thread::sleep_for(std::chrono::seconds(1));
uint32_t value;
UAVCameraManager_GetFocusRingValue(value);
LOG_INFO("camera GetFocusRingValue: {}", value);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraManagerExposureMode exposureMode;
UAVCameraManager_GetExposureMode(exposureMode);
LOG_INFO("camera GetExposureMode: {}", (int)exposureMode);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraManagerISO iso;
UAVCameraManager_GetISO(iso);
LOG_INFO("camera GetISO: {}", (int)iso);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraManagerAperture aperture;
UAVCameraManager_GetAperture(aperture);
LOG_INFO("camera GetAperture: {}", (int)aperture);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraManagerShutterSpeed shutterSpeed;
UAVCameraManager_GetShutterSpeed(shutterSpeed);
LOG_INFO("camera GetShutterSpeed: {}", (int)shutterSpeed);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraManagerExposureCompensation ev;
UAVCameraManager_GetExposureCompensation(ev);
LOG_INFO("camera GetExposureCompensation: {}", (int)ev);
std::this_thread::sleep_for(std::chrono::seconds(1));
bool enable;
UAVCameraManager_GetAELockEnabled(enable);
LOG_INFO("camera GetAELockEnabled: {}", enable);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraManagerPhotoStorageFormat format;
UAVCameraManager_GetPhotoFormat(format);
LOG_INFO("camera GetPhotoFormat: {}", (int)format);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraManagerPhotoRatio photoRatio;
UAVCameraManager_GetPhotoRatio(photoRatio);
LOG_INFO("camera GetPhotoRatio: {}", (int)photoRatio);
std::this_thread::sleep_for(std::chrono::seconds(1));
E_UAVCameraManagerMeteringMode meteringMode;
UAVCameraManager_GetMeteringMode(meteringMode);
LOG_INFO("camera GetMeteringMode: {}", (int)meteringMode);
std::this_thread::sleep_for(std::chrono::seconds(1));
}
break;
}
while(1)
std::this_thread::sleep_for(std::chrono::seconds(1));
}
int main(int argc, char *argv[])
{
T_AUserInfo usrInfo;
logger_init(std::string(argv[1]));
if(false == uav_sdk_app_info_init(&usrInfo)) {
LOG_ERROR("uav_sdk_app_info_init failed");
return -1;
}
UAV_Core_Init(&usrInfo);
UAV_Core_SetAlias("cameraV1");
UAV_Network_Init(LOCALHOST_ETHERNET);
std::thread cameraManagerThread(cameraManagerThreadFunc);
cameraManagerThread.detach();
return UAV_Core_ApplicationStart();
}