14 #include "../../include/librealsense2/h/rs_sensor.h" 15 #include "../common/fw/firmware-version.h" 44 bool register_device_notifications)
const 52 register_device_notifications);
56 register_device_notifications);
60 register_device_notifications);
62 throw std::runtime_error(
to_string() <<
"Unsupported SR300 model! 0x" 63 << std::hex << std::setw(4) << std::setfill(
'0') << (
int)pid);
69 std::shared_ptr<context>
ctx,
70 std::vector<platform::uvc_device_info>& uvc,
71 std::vector<platform::usb_device_info>& usb)
73 std::vector<platform::uvc_device_info> chosen;
74 std::vector<std::shared_ptr<device_info>> results;
78 for (
auto&
group : group_devices)
87 chosen.push_back(color);
98 chosen.push_back(depth);
101 if (!color.
pid && !depth.
pid)
108 results.push_back(
info);
120 auto raw_color_ep = std::make_shared<uvc_sensor>(
"Raw RGB Camera", ctx->get_backend().create_uvc_device(color),
123 auto color_ep = std::make_shared<sr300_color_sensor>(
this,
149 std::make_shared<auto_disabling_control>(
150 white_balance_option,
151 auto_white_balance_option));
158 std::make_shared<auto_disabling_control>(
160 auto_exposure_option));
180 using namespace ivcam;
182 auto&& backend = ctx->get_backend();
185 auto raw_depth_ep = std::make_shared<uvc_sensor>(
"Raw Depth Sensor", backend.create_uvc_device(depth),
188 auto depth_ep = std::make_shared<sr300_depth_sensor>(
this,
192 raw_depth_ep->register_xu(
depth_xu);
197 depth_ep->register_processing_block(
200 []() {
return std::make_shared<invi_converter>(
RS2_FORMAT_Y8); });
201 depth_ep->register_processing_block(
204 []() {
return std::make_shared<invi_converter>(
RS2_FORMAT_Y16); });
205 depth_ep->register_processing_block(
208 []() {
return std::make_shared<inzi_converter>(
RS2_FORMAT_Y8); });
209 depth_ep->register_processing_block(
212 []() {
return std::make_shared<inzi_converter>(
RS2_FORMAT_Y16); });
217 "Power of the SR300 projector, with 0 meaning projector off");
219 "Set the number of patterns projected per frame.\nThe higher the accuracy value the more patterns projected.\nIncreasing the number of patterns help to achieve better accuracy.\nNote that this control is affecting the Depth FPS");
221 "Motion vs. Range trade-off, with lower values allowing for better motion\nsensitivity and higher values allowing for better depth range");
223 "The confidence level threshold used by the Depth algorithm pipe to set whether\na pixel will get a valid range or will be marked with invalid range");
225 "Set the filter to apply to each depth frame.\nEach one of the filter is optimized per the application requirements");
244 return{ dims.
x, dims.
y, (c.
Kc[0][2] * 0.5f + 0.5f) * dims.
x,
245 (c.
Kc[1][2] * 0.5f + 0.5f) * dims.
y,
246 c.
Kc[0][0] * 0.5f * dims.
x,
247 c.
Kc[1][1] * 0.5f * dims.
y,
256 c.
Kt[1][2] * 0.5f + 0.5f, c.
Kt[0][0] * 0.5f,
259 if (dims.
x * 3 == dims.
y * 4)
261 intrin.
fx *= 4.0f / 3;
262 intrin.
ppx *= 4.0f / 3;
263 intrin.
ppx -= 1.0f / 6;
268 intrin.
ppx *= dims.
x;
269 intrin.
ppy *= dims.
y;
277 auto data = _hw_monitor->send(command);
279 return static_cast<float>(
t) / 100;
285 auto data = _hw_monitor->send(command);
293 _hw_monitor->send(cmd);
299 cmd.
param1 = depthEnable ? 1 : 0;
300 cmd.
param2 = colorEnable ? 1 : 0;
301 _hw_monitor->send(cmd);
310 std::vector<uint16_t>
data;
332 _hw_monitor->send(cmd);
345 _hw_monitor->send(cmd);
347 for (
auto i = 0;
i < 50;
i++)
349 _hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(),
ds::GVD);
350 this_thread::sleep_for(milliseconds(50));
352 throw std::runtime_error(
"Device still connected!");
354 catch (std::exception&
e)
366 int flash_size = 1024 * 2048;
367 int max_bulk_size = 1016;
368 int max_iterations = int(flash_size / max_bulk_size + 1);
370 std::vector<uint8_t> flash;
371 flash.reserve(flash_size);
373 for (
int i = 0;
i < max_iterations;
i++)
375 int offset = max_bulk_size *
i;
376 int size = max_bulk_size;
377 if (i == max_iterations - 1)
379 size = flash_size -
offset;
382 bool appended =
false;
384 const int retries = 3;
385 for (
int j = 0;
j < retries && !appended;
j++)
392 auto res = _hw_monitor->send(cmd);
394 flash.insert(flash.end(),
res.begin(),
res.end());
399 if (i < retries - 1) std::this_thread::sleep_for(std::chrono::milliseconds(100));
404 if (callback) callback->on_update_progress((
float)i / max_iterations);
412 throw std::runtime_error(
"update_flash is not supported by SR300");
438 auto data = _hw_monitor->send(command);
449 bool register_device_notifications)
450 :
device(ctx, group, register_device_notifications),
452 _depth_device_idx(add_sensor(create_depth_device(ctx, depth))),
457 using namespace ivcam;
458 static auto device_name =
"Intel RealSense SR3xx";
490 pose depth_to_color = {
491 transpose(reinterpret_cast<const float3x3 &>(
c.Rt)),
492 reinterpret_cast<const float3 &
>(
c.Tt) * 0.001
f 504 std::make_shared<const_value_option>(
"Number of meters represented by a single depth unit",
507 return (
c.Rmax / 1000 / 0xFFFF);
516 bool register_device_notifications)
517 :
sr3xx_camera(ctx, depth, hwm_device, group, register_device_notifications),
518 device(ctx, group, register_device_notifications),
520 _color_device_idx(
add_sensor(create_color_device(ctx, color)))
522 static auto device_name =
"Intel RealSense SR300";
532 bool register_device_notifications)
533 :
sr300_camera(ctx, color, depth, hwm_device, group, register_device_notifications),
534 device(ctx, group, register_device_notifications) {
536 static auto device_name =
"Intel RealSense SR305";
552 bool register_device_notifications)
553 :
sr3xx_camera(ctx, depth, hwm_device, group, register_device_notifications),
554 device(ctx, group, register_device_notifications) {
556 static auto device_name =
"Intel RealSense SR306";
584 std::lock_guard<std::recursive_mutex>
lock(_mtx);
586 if (has_metadata_ts(frame))
591 LOG_ERROR(
"Frame is not valid. Failed to downcast to librealsense::frame.");
602 auto sp = frame->get_stream();
603 auto bp = As<stream_profile_base, stream_profile_interface>(sp);
605 fcc = bp->get_backend_profile().format;
607 LOG_WARNING(
"UVC metadata payloads are not available for stream " 608 << std::hex << fcc << std::dec << sp->get_format()
609 <<
". Please refer to installation chapter for details.");
610 one_time_note =
true;
612 return _backup_timestamp_reader->get_frame_timestamp(frame);
618 std::lock_guard<std::recursive_mutex>
lock(_mtx);
620 if (has_metadata_fc(frame))
625 LOG_ERROR(
"Frame is not valid. Failed to downcast to librealsense::frame.");
629 return md->mode.sr300_rgb_mode.frame_counter;
632 return _backup_timestamp_reader->get_frame_counter(frame);
637 std::lock_guard<std::recursive_mutex>
lock(_mtx);
638 one_time_note =
false;
639 _backup_timestamp_reader->reset();
645 std::lock_guard<std::recursive_mutex>
lock(_mtx);
652 std::vector<std::shared_ptr<matcher>> depth_matchers;
656 for (
auto&
s : streams)
658 depth_matchers.push_back(std::make_shared<identity_matcher>(
s->get_unique_id(),
s->get_stream_type()));
660 std::vector<std::shared_ptr<matcher>> matchers;
663 matchers.push_back(std::make_shared<timestamp_composite_matcher>(depth_matchers));
667 matchers.push_back(std::make_shared<frame_number_composite_matcher>(depth_matchers));
670 return std::make_shared<timestamp_composite_matcher>(matchers);
675 std::vector<std::shared_ptr<matcher>> depth_matchers;
679 for (
auto&
s : streams)
681 depth_matchers.push_back(std::make_shared<identity_matcher>(
s->get_unique_id(),
s->get_stream_type()));
683 std::vector<std::shared_ptr<matcher>> matchers;
686 matchers.push_back(std::make_shared<timestamp_composite_matcher>(depth_matchers));
690 matchers.push_back(std::make_shared<frame_number_composite_matcher>(depth_matchers));
693 auto color_matcher = std::make_shared<identity_matcher>(_color_stream->get_unique_id(), _color_stream->get_stream_type());
694 matchers.push_back(color_matcher);
696 return std::make_shared<timestamp_composite_matcher>(matchers);
702 res.push_back(std::make_shared<threshold>());
703 res.push_back(std::make_shared<spatial_filter>());
704 res.push_back(std::make_shared<temporal_filter>());
705 res.push_back(std::make_shared<hole_filling_filter>());
static const textual_icon lock
virtual void register_option(rs2_option id, std::shared_ptr< option > option)
static processing_blocks get_sr300_depth_recommended_proccesing_blocks()
static rs2_intrinsics make_color_intrinsics(const ivcam::camera_calib_params &c, const int2 &dims)
std::shared_ptr< synthetic_sensor > create_color_device(std::shared_ptr< context > ctx, const platform::uvc_device_info &color)
std::shared_ptr< synthetic_sensor > create_depth_device(std::shared_ptr< context > ctx, const platform::uvc_device_info &depth)
const uint8_t _color_device_idx
std::vector< platform::uvc_device_info > filter_by_product(const std::vector< platform::uvc_device_info > &devices, const std::set< uint16_t > &pid_list)
ivcam::camera_calib_params get_calibration() const
rs2_extrinsics from_pose(pose a)
void assign_hw_monitor(std::shared_ptr< hw_monitor > hardware_monitor)
std::map< uint32_t, rs2_stream > sr300_color_fourcc_to_rs2_stream
void trim_device_list(std::vector< platform::usb_device_info > &devices, const std::vector< platform::usb_device_info > &chosen)
std::vector< uint8_t > backup_flash(update_progress_callback_ptr callback) override
sr305_camera(std::shared_ptr< context > ctx, const platform::uvc_device_info &color, const platform::uvc_device_info &depth, const platform::usb_device_info &hwm_device, const platform::backend_device_group &group, bool register_device_notifications)
const uint16_t SR300v2_PID
GLint GLint GLsizei GLsizei GLsizei depth
void register_same_extrinsics(const stream_interface &from, const stream_interface &to)
bool try_fetch_usb_device(std::vector< platform::usb_device_info > &devices, const platform::uvc_device_info &info, platform::usb_device_info &result)
std::shared_ptr< device_interface > create(std::shared_ptr< context > ctx, bool register_device_notifications) const override
std::shared_ptr< hw_monitor > _hw_monitor
command get_flash_logs_command() const
sr306_camera(std::shared_ptr< context > ctx, const platform::uvc_device_info &depth, const platform::usb_device_info &hwm_device, const platform::backend_device_group &group, bool register_device_notifications)
float read_mems_temp() const
std::shared_ptr< rs2_update_progress_callback > update_progress_callback_ptr
void update_flash(const std::vector< uint8_t > &image, update_progress_callback_ptr callback, int update_mode) override
command get_firmware_logs_command() const
float3x3 transpose(const float3x3 &a)
def info(name, value, persistent=False)
std::map< uint32_t, rs2_format > sr300_color_fourcc_to_rs2_format
void register_extrinsics(const stream_interface &from, const stream_interface &to, std::weak_ptr< lazy< rs2_extrinsics >> extr)
std::string hexify(const T &val)
void register_info(rs2_camera_info info, const std::string &val)
std::vector< std::vector< platform::uvc_device_info > > group_devices_by_unique_id(const std::vector< platform::uvc_device_info > &devices)
processing_blocks get_depth_recommended_proccesing_blocks()
std::shared_ptr< lazy< rs2_extrinsics > > _depth_to_color_extrinsics
platform::usb_device_info _hwm
const double TIMESTAMP_10NSEC_TO_MSEC
ivcam::camera_calib_params CalibrationParameters
void register_autorange_options()
std::map< uint32_t, rs2_format > sr300_depth_fourcc_to_rs2_format
platform::uvc_device_info _depth
const uint8_t IVCAM_DEPTH_FILTER_OPTION
uint32_t rs_fourcc(const T a, const T b, const T c, const T d)
platform::uvc_device_info get_mi(const std::vector< platform::uvc_device_info > &devices, uint32_t mi)
static processing_block_factory create_id_pbf(rs2_format format, rs2_stream stream, int idx=0)
void enter_update_state() const override
std::vector< uint8_t > data
const uint8_t IVCAM_DEPTH_MOTION_RANGE
std::map< uint32_t, rs2_stream > sr300_depth_fourcc_to_rs2_stream
std::shared_ptr< md_attribute_parser_base > make_uvc_header_parser(Attribute St::*attribute, attrib_modifyer mod=nullptr)
A utility function to create UVC metadata header parser.
lazy< ivcam::camera_calib_params > _camer_calib_params
platform::backend_device_group get_device_data() const override
void update_info(rs2_camera_info info, const std::string &val)
const platform::extension_unit depth_xu
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
const uint8_t IVCAM_DEPTH_CONFIDENCE_THRESH
static environment & get_instance()
int add_sensor(const std::shared_ptr< sensor_interface > &sensor_base)
extrinsics_graph & get_extrinsics_graph()
void set_auto_range(const ivcam::cam_auto_range_request &c) const
sensor_interface & get_sensor(size_t subdevice) override
std::shared_ptr< stream_interface > _ir_stream
void enable_timestamp(bool colorEnable, bool depthEnable) const
sr300_camera(std::shared_ptr< context > ctx, const platform::uvc_device_info &color, const platform::uvc_device_info &depth, const platform::usb_device_info &hwm_device, const platform::backend_device_group &group, bool register_device_notifications)
void create_snapshot(std::shared_ptr< debug_interface > &snapshot) const override
std::shared_ptr< stream_interface > _depth_stream
const uint8_t IVCAM_DEPTH_LASER_POWER
long long rs2_metadata_type
const uint8_t IVCAM_DEPTH_ACCURACY
void enable_recording(std::function< void(const debug_interface &)> record_action) override
void register_stream_to_extrinsic_group(const stream_interface &stream, uint32_t groupd_index)
static rs2_intrinsics make_depth_intrinsics(const ivcam::camera_calib_params &c, const int2 &dims)
#define offsetof(STRUCTURE, FIELD)
std::array< float, 3 > color
virtual std::shared_ptr< matcher > create_matcher(const frame_holder &frame) const override
sr3xx_camera(std::shared_ptr< context > ctx, const platform::uvc_device_info &depth, const platform::usb_device_info &hwm_device, const platform::backend_device_group &group, bool register_device_notifications)
platform::uvc_device_info _color
uint16_t color_temperature
static std::vector< std::shared_ptr< device_info > > pick_sr300_devices(std::shared_ptr< context > ctx, std::vector< platform::uvc_device_info > &platform, std::vector< platform::usb_device_info > &usb)
const uint16_t HW_MONITOR_BUFFER_SIZE
std::shared_ptr< stream_interface > _color_stream
std::shared_ptr< md_attribute_parser_base > make_sr300_attribute_parser(Attribute S::*attribute, unsigned long long offset, attrib_modifyer mod=nullptr)
A helper function to create a specialized attribute parser. Return it as a pointer to a base-class...
virtual std::shared_ptr< matcher > create_matcher(const frame_holder &frame) const override
void copy(void *dst, void const *src, size_t size)
synthetic_sensor & get_depth_sensor()
virtual bool supports_frame_metadata(const rs2_frame_metadata_value &frame_metadata) const =0
virtual void set_roi_method(std::shared_ptr< region_of_interest_method > roi_method)=0
bool mi_present(const std::vector< platform::uvc_device_info > &devices, uint32_t mi)
std::string to_string(T value)
rs2_timestamp_domain
Specifies the clock in relation to which the frame timestamp was measured.
void force_hardware_reset() const