Skip to content
Snippets Groups Projects
Commit e3d5e86f authored by Sebastian Hahta's avatar Sebastian Hahta
Browse files

bug/resolution

parent db2e9080
No related branches found
No related tags found
No related merge requests found
...@@ -13,8 +13,8 @@ bool DisparityToDepth::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out, ...@@ -13,8 +13,8 @@ bool DisparityToDepth::apply(ftl::rgbd::Frame &in, ftl::rgbd::Frame &out,
throw FTL_Error("Missing disparity before convert to depth"); throw FTL_Error("Missing disparity before convert to depth");
} }
const auto params = in.getLeftCamera();
const GpuMat &disp = in.get<GpuMat>(Channel::Disparity); const GpuMat &disp = in.get<GpuMat>(Channel::Disparity);
const auto params = in.getLeftCamera().scaled(disp.cols, disp.rows);
GpuMat &depth = out.create<GpuMat>(Channel::Depth); GpuMat &depth = out.create<GpuMat>(Channel::Depth);
depth.create(disp.size(), CV_32FC1); depth.create(disp.size(), CV_32FC1);
......
...@@ -304,6 +304,7 @@ Camera Camera::scaled(int width, int height) const { ...@@ -304,6 +304,7 @@ Camera Camera::scaled(int width, int height) const {
newcam.fy *= scaleY; newcam.fy *= scaleY;
newcam.cx *= scaleX; newcam.cx *= scaleX;
newcam.cy *= scaleY; newcam.cy *= scaleY;
newcam.doffs *= scaleX;
return newcam; return newcam;
} }
......
...@@ -76,6 +76,14 @@ double Calibrate::getBaseline() const { ...@@ -76,6 +76,14 @@ double Calibrate::getBaseline() const {
return cv::norm(t_); return cv::norm(t_);
} }
double Calibrate::getDoff() const {
return -(Q_.at<double>(3,3) * getBaseline());
}
double Calibrate::getDoff(const Size& size) const {
return getDoff() * ((double) size.width / (double) img_size_.width);
}
Mat Calibrate::getCameraMatrixLeft(const cv::Size res) { Mat Calibrate::getCameraMatrixLeft(const cv::Size res) {
if (rectify_) { if (rectify_) {
return ftl::calibration::scaleCameraMatrix(Mat(P1_, cv::Rect(0, 0, 3, 3)), res, img_size_); return ftl::calibration::scaleCameraMatrix(Mat(P1_, cv::Rect(0, 0, 3, 3)), res, img_size_);
......
...@@ -53,12 +53,14 @@ class Calibrate : public ftl::Configurable { ...@@ -53,12 +53,14 @@ class Calibrate : public ftl::Configurable {
/** /**
* @brief Get disparity to depth matrix * @brief Get disparity to depth matrix
* * @note Disparity offset is in image_size (scale)
*
* 2020/01/15: StereoVideoSource creates a Camera object which is used to * 2020/01/15: StereoVideoSource creates a Camera object which is used to
* calculate depth from disparity (disp2depth.cu). Seems to be * calculate depth from disparity (disp2depth.cu). Seems to be
* used only in StereoVideoSource to get doff and baseline * used only in StereoVideoSource to get doff and baseline
* parameter values in updateParameters() * parameter values in updateParameters()
*/ */
[[deprecated]]
const cv::Mat &getQ() const { return Q_; } const cv::Mat &getQ() const { return Q_; }
/** /**
...@@ -66,6 +68,15 @@ class Calibrate : public ftl::Configurable { ...@@ -66,6 +68,15 @@ class Calibrate : public ftl::Configurable {
*/ */
double getBaseline() const; double getBaseline() const;
/**
* @brief Get camera pair disparity offset
* @param size (optional) scale to given resolution.
*
* Returns disparity offset for image_size resolution if size not provided.
*/
double getDoff() const;
double getDoff(const cv::Size& size) const;
/** /**
* @brief Get intrinsic paramters. If rectification is enabled, returns * @brief Get intrinsic paramters. If rectification is enabled, returns
* rectified intrinsic parameters, otherwise returns values from * rectified intrinsic parameters, otherwise returns values from
......
...@@ -202,7 +202,7 @@ void StereoVideoSource::updateParameters() { ...@@ -202,7 +202,7 @@ void StereoVideoSource::updateParameters() {
// same for left and right // same for left and right
float baseline = static_cast<float>(calib_->getBaseline()); float baseline = static_cast<float>(calib_->getBaseline());
float doff = static_cast<float>(-calib_->getQ().at<double>(3,3) * baseline); float doff = calib_->getDoff(color_size_);
double d_resolution = this->host_->getConfig().value<double>("depth_resolution", 0.0); double d_resolution = this->host_->getConfig().value<double>("depth_resolution", 0.0);
float min_depth = this->host_->getConfig().value<double>("min_depth", 0.45); float min_depth = this->host_->getConfig().value<double>("min_depth", 0.45);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment