5 #ifndef LIBREALSENSE_ZR300_H 6 #define LIBREALSENSE_ZR300_H 43 return sizeof(kf) +
sizeof(distf);
53 return{ 640, 480, kf[2], kf[5], kf[0], kf[4],
RS_DISTORTION_FTHETA, { distf[0], 0, 0, 0, 0 } };
64 return{ { rotation[0], rotation[1], rotation[2],
65 rotation[3], rotation[4], rotation[5],
66 rotation[6], rotation[7], rotation[8] },
67 { translation[0], translation[1], translation[2] } };
72 return sizeof(rotation) +
sizeof(translation);
91 return sizeof(fe_to_imu) +
sizeof(fe_to_depth) +
sizeof(rgb_to_imu) +
sizeof(depth_to_imu);
110 float acc_bias_variance[3];
111 float acc_noise_variance[3];
112 float gyro_bias_variance[3];
113 float gyro_noise_variance[3];
118 return sizeof(acc_intrinsic) +
sizeof(gyro_intrinsic) +
119 sizeof(acc_bias_variance) +
sizeof(acc_noise_variance) +
sizeof(gyro_bias_variance) +
sizeof(gyro_noise_variance);
131 for (
auto i = 0; i < 3; i++)
133 for (
auto j = 0; j < 4; j++)
135 res.
data[i][j] = intrin.
val[i][j];
139 for (
auto i = 0; i < 3; i++)
148 return convert(acc_intrinsic, acc_bias_variance, acc_noise_variance);
153 return convert(gyro_intrinsic, gyro_bias_variance, gyro_noise_variance);
158 return{ get_acc_intrinsic(), get_gyro_intrinsic() };
187 is_auto_exposure(true),
195 void set_auto_exposure_state(
rs_option option,
double value);
198 bool is_auto_exposure;
201 unsigned sample_rate;
202 unsigned skip_frames;
208 void modify_exposure(
float& exposure_value,
bool& exp_modified,
float& gain_value,
bool& gain_modified);
214 struct histogram_metric {
int under_exposure_count;
int over_exposure_count;
int shadow_limit;
int highlight_limit;
int lower_q;
int upper_q;
float main_mean;
float main_std; };
215 enum class rounding_mode_type { round, ceil, floor };
217 inline void im_hist(
const uint8_t* data,
const int width,
const int height,
const int rowStep,
int h[]);
218 void increase_exposure_target(
float mult,
float& target_exposure);
219 void decrease_exposure_target(
float mult,
float& target_exposure);
220 void increase_exposure_gain(
const float& target_exposure,
const float& target_exposure0,
float& exposure,
float& gain);
221 void decrease_exposure_gain(
const float& target_exposure,
const float& target_exposure0,
float& exposure,
float& gain);
222 void static_increase_exposure_gain(
const float& target_exposure,
const float& target_exposure0,
float& exposure,
float& gain);
223 void static_decrease_exposure_gain(
const float& target_exposure,
const float& target_exposure0,
float& exposure,
float& gain);
224 void anti_flicker_increase_exposure_gain(
const float& target_exposure,
const float& target_exposure0,
float& exposure,
float& gain);
225 void anti_flicker_decrease_exposure_gain(
const float& target_exposure,
const float& target_exposure0,
float& exposure,
float& gain);
226 void hybrid_increase_exposure_gain(
const float& target_exposure,
const float& target_exposure0,
float& exposure,
float& gain);
227 void hybrid_decrease_exposure_gain(
const float& target_exposure,
const float& target_exposure0,
float& exposure,
float& gain);
229 #if defined(_WINDOWS) || defined(WIN32) || defined(WIN64) 230 inline float round(
float x) {
return std::round(x); }
232 inline float round(
float x) {
return x < 0.0 ? std::ceil(x - 0.5f) : std::floor(x + 0.5f); }
235 float exposure_to_value(
float exp_ms, rounding_mode_type rounding_mode);
236 float gain_to_value(
float gain, rounding_mode_type rounding_mode);
237 template <
typename T>
inline T sqr(
const T& x) {
return (x*x); }
238 void histogram_score(std::vector<int>& h,
const int total_weight, histogram_metric& score);
241 float minimal_exposure = 0.1f, maximal_exposure = 20.f, base_gain = 2.0f, gain_limit = 15.0f;
242 float exposure = 10.0f, gain = 2.0f, target_exposure = 0.0f;
243 uint8_t under_exposure_limit = 5, over_exposure_limit = 250;
int under_exposure_noise_limit = 50, over_exposure_noise_limit = 50;
244 int direction = 0, prev_direction = 0;
float hysteresis = 0.075f;
245 float eps = 0.01f, exposure_step = 0.1f, minimal_exposure_step = 0.01f;
247 std::recursive_mutex state_mutex;
254 void add_frame(
rs_frame_ref* frame, std::shared_ptr<rsimpl::frame_archive> archive);
266 size_t get_queue_size();
270 bool try_get_exp_by_frame_cnt(
double& exposure,
const unsigned long long frame_counter);
272 const std::size_t max_size_of_exp_and_cnt_queue = 10;
275 std::shared_ptr<rsimpl::frame_archive> sync_archive;
276 std::shared_ptr<std::thread> exposure_thread;
277 std::condition_variable cv;
278 std::atomic<bool> keep_alive;
279 std::deque<rs_frame_ref*> data_queue;
280 std::mutex queue_mtx;
281 std::atomic<unsigned> frames_counter;
282 std::atomic<unsigned> skip_frames;
283 std::deque<exposure_and_frame_counter> exposure_and_frame_counter_queue;
284 std::mutex exp_and_cnt_queue_mtx;
292 std::shared_ptr<auto_exposure_mechanism> auto_exposure;
293 std::atomic<bool> to_add_frames;
296 void toggle_motion_module_power(
bool bOn);
297 void toggle_motion_module_events(
bool bOn);
298 void on_before_callback(
rs_stream ,
rs_frame_ref *, std::shared_ptr<rsimpl::frame_archive>)
override;
306 void get_option_range(
rs_option option,
double & min,
double & max,
double & step,
double & def)
override;
307 void set_options(
const rs_option options[],
size_t count,
const double values[])
override;
308 void get_options(
const rs_option options[],
size_t count,
double values[])
override;
309 void send_blob_to_device(
rs_blob_type type,
void * data,
int size)
override;
312 void start_motion_tracking()
override;
313 void stop_motion_tracking()
override;
318 rs_stream select_key_stream(
const std::vector<rsimpl::subdevice_mode_selection> & selected_modes)
override;
322 unsigned long long get_frame_counter_by_usb_cmd();
328 void set_fw_logger_option(
double value);
329 unsigned get_fw_logger_option();
331 bool validate_motion_extrinsics(
rs_stream)
const;
332 bool validate_motion_intrinsics()
const;
337 std::shared_ptr<rs_device>
make_zr300_device(std::shared_ptr<uvc::device> device);
exposure_and_frame_counter(double exposure, unsigned long long frame_counter)
Definition: zr300.h:258
bool has_data() const
Definition: zr300.h:122
byte CRC32[4]
Definition: zr300.h:23
mm_extrinsic rgb_to_imu
Definition: zr300.h:85
rs_motion_device_intrinsic get_acc_intrinsic() const
Definition: zr300.h:146
mm_extrinsic fe_to_imu
Definition: zr300.h:83
int get_data_size() const
Definition: zr300.h:41
rs_blob_type
Definition: rs.h:219
struct rs_intrinsics rs_intrinsics
IMU_version ver
Definition: zr300.h:36
float data[3][4]
Definition: rs.h:306
bool has_data() const
Definition: zr300.h:75
IMU_version ver
Definition: zr300.h:107
MM_intrinsics acc_intrinsic
Definition: zr300.h:108
rs_option
Definition: rs.h:120
int get_data_size() const
Definition: zr300.h:116
serial_number sn
Definition: zr300.h:170
int get_data_size() const
Definition: zr300.h:70
MM_intrinsics gyro_intrinsic
Definition: zr300.h:109
option
Definition: rs.hpp:82
struct rs_extrinsics rs_extrinsics
float noise_variances[3]
Definition: rs.h:308
Definition: motion-module.h:176
int get_data_size() const
Definition: zr300.h:89
byte size
Definition: zr300.h:22
IMU_intrinsic imu_intrinsic
Definition: zr300.h:166
calibration calib
Definition: zr300.h:171
IMU_version ver
Definition: zr300.h:82
float bias_variances[3]
Definition: rs.h:309
Definition: ds-device.h:30
mm_extrinsic depth_to_imu
Definition: zr300.h:86
bool check_not_all_zeros(std::vector< byte > data)
Definition: types.h:643
source
Definition: rs.hpp:212
unsigned get_auto_exposure_state(rs_option option) const
IMU_extrinsic mm_extrinsic
Definition: zr300.h:165
std::shared_ptr< rs_device > make_zr300_device(std::shared_ptr< uvc::device > device)
rs_source
Definition: rs.h:83
struct rs_motion_intrinsics rs_motion_intrinsics
mm_extrinsic fe_to_depth
Definition: zr300.h:84
motion_module_calibration read_fisheye_intrinsic(uvc::device &device)
unsigned long long frame_counter
Definition: zr300.h:260
bool has_data() const
Definition: zr300.h:46
uint8_t byte
Definition: types.h:42
exposure_and_frame_counter()
Definition: zr300.h:257
rs_stream
Definition: rs.h:27
double exposure
Definition: zr300.h:259
rs_motion_device_intrinsic get_gyro_intrinsic() const
Definition: zr300.h:151
IMU_version ver
Definition: zr300.h:28
fisheye_auto_exposure_state()
Definition: zr300.h:186
float val[3][4]
Definition: zr300.h:101
Definition: motion-module.h:87
auto_exposure_modes
Definition: zr300.h:177
Definition: rscore.hpp:44
fisheye_intrinsic fe_intrinsic
Definition: zr300.h:164
rs_motion_device_intrinsic convert(const MM_intrinsics &intrin, const float bias_variance[3], const float noises_variance[3]) const
Definition: zr300.h:127
byte ver[4]
Definition: zr300.h:21
std::timed_mutex usbMutex
Definition: zr300.h:300