135 const uvc::guid IVCAM_WIN_USB_DEVICE_GUID = { 0x175695CD, 0x30D9, 0x4F87, {0x8B, 0xE3, 0x5A, 0x82, 0x70, 0xF4, 0x9A, 0x31} };
139 size_t prepare_usb_command(uint8_t * request,
size_t & requestSize, uint32_t op, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4, uint8_t *
data,
size_t dataLength)
145 size_t index =
sizeof(uint16_t);
147 index +=
sizeof(uint16_t);
148 *(uint32_t *)(request + index) = op;
149 index +=
sizeof(uint32_t);
150 *(uint32_t *)(request + index) = p1;
151 index +=
sizeof(uint32_t);
152 *(uint32_t *)(request + index) = p2;
153 index +=
sizeof(uint32_t);
154 *(uint32_t *)(request + index) = p3;
155 index +=
sizeof(uint32_t);
156 *(uint32_t *)(request + index) = p4;
157 index +=
sizeof(uint32_t);
161 memcpy(request + index, data, dataLength);
166 *(uint16_t *)request = (uint16_t)(index -
sizeof(uint32_t));
173 void get_gvd(uvc::device & device, std::timed_mutex & mutex,
size_t sz,
char * gvd,
int gvd_cmd)
183 std::vector<char> gvd(1024);
184 get_gvd(device, mutex, 1024, gvd.data(), gvd_cmd);
186 memcpy(fws, gvd.data() +
offset, 8);
187 version =
std::string(std::to_string(fws[3]) +
"." + std::to_string(fws[2]) +
"." + std::to_string(fws[1]) +
"." + std::to_string(fws[0]));
192 std::vector<char> gvd(1024);
193 get_gvd(device, mutex, 1024, gvd.data());
195 memcpy(ss, gvd.data() +
offset, 8);
196 char formattedBuffer[64];
199 sprintf(formattedBuffer,
"%02X%02X%02X%02X%02X%02X", ss[0], ss[1], ss[2], ss[3], ss[4], ss[5]);
202 else if (offset == 132)
204 sprintf(formattedBuffer,
"%02X%02X%02X%02X%02X%-2X", ss[0], ss[1], ss[2], ss[3], ss[4], ss[5]);
216 void enable_timestamp(uvc::device & device, std::timed_mutex & mutex,
bool colorEnable,
bool depthEnable)
218 hwmon_cmd cmd((uint8_t)fw_cmd::TimeStampEnable);
219 cmd.
Param1 = depthEnable ? 1 : 0;
220 cmd.
Param2 = colorEnable ? 1 : 0;
224 void set_auto_range(uvc::device & device, std::timed_mutex & mutex,
int enableMvR, int16_t minMvR, int16_t maxMvR, int16_t startMvR,
int enableLaser, int16_t minLaser, int16_t maxLaser, int16_t startLaser, int16_t ARUpperTH, int16_t ARLowerTH)
226 hwmon_cmd CommandParameters((uint8_t)fw_cmd::SetAutoRange);
227 CommandParameters.
Param1 = enableMvR;
228 CommandParameters.
Param2 = enableLaser;
230 auto data =
reinterpret_cast<int16_t *
>(CommandParameters.
data);
236 data[5] = startLaser;
257 hwmon_cmd cmd((uint8_t)fw_cmd::GetFWLastError);
258 memset(cmd.
data, 0, 4);
332 return static_cast<float>(
t) / 100;
353 size_t requestSize =
sizeof(request);
357 throw std::runtime_error(
"usb transfer to retrieve calibration data failed");
358 execute_usb_command(device, usbMutex, request, requestSize, responseOp, data, bytesReturned);
364 for (
int i = 0; i <
bufsize; i++)
371 uint8_t valid[2] = { 0X14, 0x0A };
372 if (memcmp(valid, validation, 2) != 0)
return 0;
376 std::tuple<ivcam::camera_calib_params, cam_temperature_data, thermal_loop_params>
get_f200_calibration(uint8_t * rawCalibData,
size_t len)
378 uint8_t * bufParams = rawCalibData + 4;
389 rawCalibData = rawCalibData + 4;
395 memcpy((uint8_t*)&d +
sizeof(
int),
data, size -
sizeof(
int));
398 fixWithVersionInfo(CalibrationData, (
int)size, rawCalibData);
406 memcpy((uint8_t*)&TesterData + SIZE_OF_CALIB_HEADER_BYTES, rawCalibData + EndOfCalibratioData,
sizeof(
IVCAMTesterData) - SIZE_OF_CALIB_HEADER_BYTES);
412 float *
params = (
float *)bufParams;
422 throw std::runtime_error(
"calibration table is not compatible with this API");
425 std::tuple<ivcam::camera_calib_params, cam_temperature_data, thermal_loop_params>
read_f200_calibration(uvc::device & device, std::timed_mutex & mutex)
435 auto params = compensated_calibration;
438 bool isQres = resolution[0] == 640 && resolution[1] == 360;
448 float width = (float)resolution[0] * scale;
449 float height = (float)resolution[1];
451 int PrecisionBits = 16;
453 int TexturePrecisionBits = 12;
454 float ypscale = (float)(1 << (CodeBits + 1 - 10));
457 float s1 = (float)(1 << (PrecisionBits)) / 2047;
458 float s2 = (float)(1 << (CodeBits)) - ypscale*0.5
f;
462 float gamma = 2 / (height*
params.Kc[1][1]);
465 float a = alpha / gamma;
467 float b = 0.5f*scale*
a + beta / gamma;
468 float c = 0.5f*a1 + delta / gamma;
471 float d1 =
params.Invdistc[0] * pow(gamma, (
float)2.0);
472 float d2 =
params.Invdistc[1] * pow(gamma, (
float)4.0);
473 float d5 = (float)((
double)(
params.Invdistc[4]) * pow((
double)gamma, 6.0));
474 float d3 =
params.Invdistc[2] * gamma;
475 float d4 =
params.Invdistc[3] * gamma;
477 float q = 1 / pow(gamma, (
float)2.0);
487 float p3 = -
params.Pp[2][0];
488 float p4 = -
params.Pp[2][1];
489 float p5 = -
params.Pp[2][2] / gamma;
492 float p8 = s2*(
params.Pp[1][2] +
params.Pp[2][2]) / gamma;
506 float f7 = 2 *
params.Pp[2][2] / (
params.Pp[0][0] +
params.Pp[2][0]) / sreproj / gamma;
516 float f11 = 1 /
params.Kp[0][0];
529 float suv = (float)((1 << TexturePrecisionBits) - 1);
553 float o3 = 1 / s2 /
params.Kp[1][1];
556 float dp1 =
params.Distp[0];
557 float dp2 =
params.Distp[1];
558 float dp3 =
params.Distp[2];
559 float dp4 =
params.Distp[3];
560 float dp5 =
params.Distp[4];
562 float ip0 =
params.Kp[1][1] * s2;
574 d3,d4,d5,
q,p1,p2,p3,p4,p5,p6,p7,p8,h0,h1,h2,h3,h4,h5,h6,h7,h8,h9,h10,h11,f0,f1,
575 f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,o1,o2,o3,o4,dp1,dp2,dp3,dp4,dp5,ip0,ip1,ip2,ip3,
576 ip4,ip5,ypscale,ypoff,0,0 };
610 uint8_t reserved21[148];
626 command.
Param1 = (uint32_t)cam_data_source::TakeFromRAM;
640 memcpy(&rawCalib, rawCalibrationBuffer, std::min(
sizeof(rawCalib), bufferLength));
void get_filter_option(const uvc::device &device, uint8_t &filter_option)
cam_temperature_data TemperatureData
void update_asic_coefficients(uvc::device &device, std::timed_mutex &mutex, const ivcam::camera_calib_params &compensated_params)
void get_motion_range(const uvc::device &device, uint8_t &motion_range)
size_t receivedCommandDataLength
void xu_read(const uvc::device &device, uint8_t xu_ctrl, void *buffer, uint32_t length)
void get_laser_power(const uvc::device &device, uint8_t &laser_power)
void get_f200_calibration_raw_data(uvc::device &device, std::timed_mutex &usbMutex, uint8_t *data, size_t &bytesReturned)
int get_version_of_calibration(uint8_t *validation, uint8_t *version)
const uint8_t NUM_OF_CALIBRATION_COEFFS
const uint8_t IVCAM_MONITOR_INTERFACE
GLint GLint GLsizei GLsizei height
int sizeOfSendCommandData
float CoefValueArray[NUM_OF_CALIBRATION_COEFFS]
GLenum GLenum GLenum GLenum GLenum scale
void set_dynamic_fps(uvc::device &device, uint8_t dynamic_fps)
int bcdtoint(uint8_t *buf, int bufsize)
uint8_t data[HW_MONITOR_BUFFER_SIZE]
GLsizei const GLchar *const * string
void generate_asic_calibration_coefficients(const ivcam::camera_calib_params &compensated_calibration, std::vector< int > resolution, const bool isZMode, float *values)
GLenum GLuint GLenum GLsizei const GLchar * buf
void set_auto_range(uvc::device &device, std::timed_mutex &mutex, int enableMvR, int16_t minMvR, int16_t maxMvR, int16_t startMvR, int enableLaser, int16_t minLaser, int16_t maxLaser, int16_t startLaser, int16_t ARUpperTH, int16_t ARLowerTH)
GLenum GLuint GLsizei bufsize
void force_hardware_reset(uvc::device &device, std::timed_mutex &mutex)
int read_ir_temp(uvc::device &device, std::timed_mutex &mutex)
uint8_t receivedCommandData[HW_MONITOR_BUFFER_SIZE]
ivcam::camera_calib_params CalibrationParameters
const uint16_t IVCAM_MONITOR_MAGIC_NUMBER
void set_confidence_threshold(uvc::device &device, uint8_t conf_thresh)
GLfloat GLfloat GLfloat alpha
void execute_usb_command(uvc::device &device, std::timed_mutex &mutex, uint8_t *out, size_t outSize, uint32_t &op, uint8_t *in, size_t &inSize)
void perform_and_send_monitor_command(uvc::device &device, std::timed_mutex &mutex, hwmon_cmd &newCommand)
void xu_write(uvc::device &device, uint8_t xu_ctrl, void *buffer, uint32_t length)
void get_control_with_retry(const device &device, const extension_unit &xu, uint8_t ctrl, void *data, int len)
OACOffsetData OACOffsetData_
void get_confidence_threshold(const uvc::device &device, uint8_t &conf_thresh)
void set_laser_power(uvc::device &device, uint8_t laser_power)
void get_dynamic_fps(const uvc::device &device, uint8_t &dynamic_fps)
ivcam::camera_calib_params read_sr300_calibration(uvc::device &device, std::timed_mutex &mutex)
const uvc::extension_unit depth_xu
void get_accuracy(const uvc::device &device, uint8_t &accuracy)
void get_module_serial_string(uvc::device &device, std::timed_mutex &mutex, std::string &serial, int offset)
const uint8_t SIZE_OF_CALIB_HEADER_BYTES
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * data
std::tuple< ivcam::camera_calib_params, cam_temperature_data, thermal_loop_params > get_f200_calibration(uint8_t *rawCalibData, size_t len)
const uint8_t IVCAM_DEPTH_DYNAMIC_FPS
const uint16_t SIZE_OF_CALIB_PARAM_BYTES
void set_filter_option(uvc::device &device, uint8_t filter_option)
const uint8_t IVCAM_DEPTH_ACCURACY
void set_asic_coefficients(uvc::device &device, std::timed_mutex &mutex, const cam_asic_coefficients &coeffs)
const uint8_t IVCAM_MIN_SUPPORTED_VERSION
void set_accuracy(uvc::device &device, uint8_t accuracy)
GLboolean GLboolean GLboolean GLboolean a
float read_mems_temp(uvc::device &device, std::timed_mutex &mutex)
const uint16_t HW_MONITOR_BUFFER_SIZE
FirmwareError get_fw_last_error(uvc::device &device, std::timed_mutex &mutex)
GLboolean GLboolean GLboolean b
void claim_interface(device &device, const guid &interface_guid, int interface_number)
void get_firmware_version_string(uvc::device &device, std::timed_mutex &mutex, std::string &version, int gvd_cmd, int offset)
GLenum GLsizei GLsizei GLint * values
void get_sr300_calibration_raw_data(uvc::device &device, std::timed_mutex &mutex, uint8_t *data, size_t &bytesReturned)
GLint GLint GLsizei width
thermal_loop_params ThermalLoopParams
void set_control_with_retry(device &device, const extension_unit &xu, uint8_t ctrl, void *data, int len)
const uint8_t IVCAM_DEPTH_MOTION_RANGE
const uint8_t IVCAM_DEPTH_FILTER_OPTION
GLuint GLsizei GLsizei * length
const uint8_t IVCAM_MONITOR_HEADER_SIZE
std::tuple< ivcam::camera_calib_params, cam_temperature_data, thermal_loop_params > read_f200_calibration(uvc::device &device, std::timed_mutex &mutex)
GLdouble GLdouble GLdouble GLdouble q
void enable_timestamp(uvc::device &device, std::timed_mutex &mutex, bool colorEnable, bool depthEnable)
void get_gvd(uvc::device &device, std::timed_mutex &mutex, size_t sz, char *gvd, int gvd_cmd)
size_t prepare_usb_command(uint8_t *request, size_t &requestSize, uint32_t op, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4, uint8_t *data, size_t dataLength)
void set_motion_range(uvc::device &device, uint8_t motion_range)
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
void claim_ivcam_interface(uvc::device &device)
const uint8_t IVCAM_DEPTH_CONFIDENCE_THRESH
ivcam::camera_calib_params CalibrationParameters
const uint8_t IVCAM_DEPTH_LASER_POWER
GLdouble GLdouble GLdouble r
GLenum GLenum const GLfloat * coeffs