Skip to content
Snippets Groups Projects
Commit 0a88bb66 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fix realsense render baseline bug

parent 6d981ed8
No related branches found
No related tags found
1 merge request!316Resolves #343 GUI and Frame Refactor
...@@ -2,11 +2,27 @@ ...@@ -2,11 +2,27 @@
#include <loguru.hpp> #include <loguru.hpp>
#include <ftl/threads.hpp> #include <ftl/threads.hpp>
#include <ftl/rgbd/source.hpp> #include <ftl/rgbd/source.hpp>
#include <ftl/rgbd/capabilities.hpp>
using ftl::rgbd::detail::RealsenseSource; using ftl::rgbd::detail::RealsenseSource;
using std::string; using std::string;
using ftl::codecs::Channel; using ftl::codecs::Channel;
using cv::cuda::GpuMat; using cv::cuda::GpuMat;
using ftl::rgbd::Capability;
static std::string get_device_name(const rs2::device& dev) {
// Each device provides some information on itself, such as name:
std::string name = "Unknown Device";
if (dev.supports(RS2_CAMERA_INFO_NAME))
name = dev.get_info(RS2_CAMERA_INFO_NAME);
// and the serial number of the device:
std::string sn = "########";
if (dev.supports(RS2_CAMERA_INFO_SERIAL_NUMBER))
sn = std::string("#") + dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER);
return name + " " + sn;
}
RealsenseSource::RealsenseSource(ftl::rgbd::Source *host) RealsenseSource::RealsenseSource(ftl::rgbd::Source *host)
: ftl::rgbd::BaseSourceImpl(host), align_to_depth_(RS2_STREAM_COLOR) { : ftl::rgbd::BaseSourceImpl(host), align_to_depth_(RS2_STREAM_COLOR) {
...@@ -20,11 +36,13 @@ RealsenseSource::RealsenseSource(ftl::rgbd::Source *host) ...@@ -20,11 +36,13 @@ RealsenseSource::RealsenseSource(ftl::rgbd::Source *host)
//pipe_.start(cfg); //pipe_.start(cfg);
rs2::pipeline_profile profile = pipe_.start(cfg); rs2::pipeline_profile profile = pipe_.start(cfg);
rs2::device dev = profile.get_device(); rs2::device dev = profile.get_device();
name_ = get_device_name(dev);
rs2_intrinsics intrin = profile.get_stream(rs2_stream::RS2_STREAM_DEPTH).as<rs2::video_stream_profile>().get_intrinsics(); rs2_intrinsics intrin = profile.get_stream(rs2_stream::RS2_STREAM_DEPTH).as<rs2::video_stream_profile>().get_intrinsics();
rs2::depth_sensor ds = dev.query_sensors().front().as<rs2::depth_sensor>(); rs2::depth_sensor ds = dev.query_sensors().front().as<rs2::depth_sensor>();
scale_ = ds.get_depth_scale(); scale_ = ds.get_depth_scale();
LOG(INFO) << "RS Scale = " << scale_;
LOG(INFO) << "Realsense device: " << name_;
params_.width = intrin.width; params_.width = intrin.width;
params_.height = intrin.height; params_.height = intrin.height;
...@@ -35,6 +53,7 @@ RealsenseSource::RealsenseSource(ftl::rgbd::Source *host) ...@@ -35,6 +53,7 @@ RealsenseSource::RealsenseSource(ftl::rgbd::Source *host)
params_.maxDepth = 3.0; params_.maxDepth = 3.0;
params_.minDepth = 0.1; params_.minDepth = 0.1;
params_.doffs = 0.0; params_.doffs = 0.0;
params_.baseline = 0.055f; // TODO: Get from device extrinsics
do_update_params_ = true; do_update_params_ = true;
...@@ -56,6 +75,20 @@ bool RealsenseSource::retrieve(ftl::rgbd::Frame &frame) { ...@@ -56,6 +75,20 @@ bool RealsenseSource::retrieve(ftl::rgbd::Frame &frame) {
do_update_params_ = false; do_update_params_ = false;
frame.setLeft() = params_; frame.setLeft() = params_;
frame.setPose() = Eigen::Matrix4d::Identity(); frame.setPose() = Eigen::Matrix4d::Identity();
auto &meta = frame.create<std::map<std::string,std::string>>(Channel::MetaData);
meta["name"] = host_->value("name", host_->getID());
meta["id"] = host_->getID();
meta["uri"] = host_->value("uri", std::string(""));
meta["device"] = name_;
if (!frame.has(Channel::Capabilities)) {
auto &cap = frame.create<std::unordered_set<Capability>>(Channel::Capabilities);
cap.emplace(Capability::VIDEO);
cap.emplace(Capability::LIVE);
cap.emplace(Capability::ACTIVE);
cap.emplace(Capability::ADJUSTABLE);
}
} }
rs2::frameset frames; rs2::frameset frames;
......
...@@ -31,6 +31,7 @@ class RealsenseSource : public ftl::rgbd::BaseSourceImpl { ...@@ -31,6 +31,7 @@ class RealsenseSource : public ftl::rgbd::BaseSourceImpl {
rs2::align align_to_depth_; rs2::align align_to_depth_;
rs2::frame rscolour_; rs2::frame rscolour_;
ftl::rgbd::Camera params_; ftl::rgbd::Camera params_;
std::string name_;
}; };
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment