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

fix parameter scalign (resolution)

parent bd655dbc
No related branches found
No related tags found
1 merge request!196High resolution colour
Pipeline #17080 passed
...@@ -82,8 +82,8 @@ static Eigen::Affine3d create_rotation_matrix(float ax, float ay, float az) { ...@@ -82,8 +82,8 @@ static Eigen::Affine3d create_rotation_matrix(float ax, float ay, float az) {
return rz * rx * ry; return rz * rx * ry;
} }
// TODO: * Remove this class (requires more general solution). Also does not // TODO: * Remove this class (requires more general solution). Also does
// process disconnections/reconnections/types etc. correctly. // not process disconnections/reconnections/types etc. correctly.
// * Update when new options become available. // * Update when new options become available.
class ConfigProxy { class ConfigProxy {
...@@ -216,6 +216,7 @@ static void run(ftl::Configurable *root) { ...@@ -216,6 +216,7 @@ static void run(ftl::Configurable *root) {
for (auto &input : sources) { for (auto &input : sources) {
string uri = input->getURI(); string uri = input->getURI();
auto T = transformations.find(uri); auto T = transformations.find(uri);
if (T == transformations.end()) { if (T == transformations.end()) {
LOG(WARNING) << "Camera pose for " + uri + " not found in transformations"; LOG(WARNING) << "Camera pose for " + uri + " not found in transformations";
......
...@@ -303,11 +303,6 @@ void Source::notify(int64_t ts, cv::cuda::GpuMat &c1, cv::cuda::GpuMat &c2) { ...@@ -303,11 +303,6 @@ void Source::notify(int64_t ts, cv::cuda::GpuMat &c1, cv::cuda::GpuMat &c2) {
int max_width = max(impl_->params_.width, max(c1.cols, c2.cols)); int max_width = max(impl_->params_.width, max(c1.cols, c2.cols));
int max_height = max(impl_->params_.height, max(c1.rows, c2.rows)); int max_height = max(impl_->params_.height, max(c1.rows, c2.rows));
// Do we need to scale camera parameters
if (impl_->params_.width < max_width || impl_->params_.height < max_height) {
impl_->params_ = impl_->params_.scaled(max_width, max_height);
}
if (callback_) callback_(ts, c1, c2); if (callback_) callback_(ts, c1, c2);
} }
......
...@@ -49,20 +49,12 @@ class Calibrate : public ftl::Configurable { ...@@ -49,20 +49,12 @@ class Calibrate : public ftl::Configurable {
void updateCalibration(const ftl::rgbd::Camera &p); void updateCalibration(const ftl::rgbd::Camera &p);
/** // Get disparity to depth matrix.
* Get the camera matrix. Used to convert disparity map back to depth and
* a 3D point cloud.
*/
const cv::Mat &getQ() const { return Q_; } const cv::Mat &getQ() const { return Q_; }
cv::Mat getCameraMatrixLeft(const cv::Size res); cv::Mat getCameraMatrixLeft(const cv::Size res);
cv::Mat getCameraMatrixRight(const cv::Size res); cv::Mat getCameraMatrixRight(const cv::Size res);
// TODO: Remove. Always require resolution for correct scaling
const cv::Mat &getCameraMatrixLeft() { return Kl_; }
const cv::Mat &getCameraMatrixRight() { return Kr_; }
const cv::Mat &getCameraMatrix() { return getCameraMatrixLeft(); }
private: private:
void _updateIntrinsics(); void _updateIntrinsics();
bool _loadCalibration(cv::Size img_size, std::pair<cv::Mat, cv::Mat> &map1, std::pair<cv::Mat, cv::Mat> &map2); bool _loadCalibration(cv::Size img_size, std::pair<cv::Mat, cv::Mat> &map1, std::pair<cv::Mat, cv::Mat> &map2);
......
...@@ -151,22 +151,22 @@ void StereoVideoSource::init(const string &file) { ...@@ -151,22 +151,22 @@ void StereoVideoSource::init(const string &file) {
} }
ftl::rgbd::Camera StereoVideoSource::parameters(Channel chan) { ftl::rgbd::Camera StereoVideoSource::parameters(Channel chan) {
cv::Mat q; cv::Mat K;
if (chan == Channel::Right) { if (chan == Channel::Right) {
q = calib_->getCameraMatrixRight(depth_size_); K = calib_->getCameraMatrixRight(depth_size_);
} else { } else {
q = calib_->getCameraMatrixLeft(depth_size_); K = calib_->getCameraMatrixLeft(depth_size_);
} }
// TODO: remove hardcoded values (min/max) // TODO: remove hardcoded values (min/max)
ftl::rgbd::Camera params = { ftl::rgbd::Camera params = {
q.at<double>(0,0), // Fx K.at<double>(0,0), // Fx
q.at<double>(1,1), // Fy K.at<double>(1,1), // Fy
-q.at<double>(0,2), // Cx -K.at<double>(0,2), // Cx
-q.at<double>(1,2), // Cy -K.at<double>(1,2), // Cy
(unsigned int)lsrc_->width(), (unsigned int) depth_size_.width,
(unsigned int)lsrc_->height(), (unsigned int) depth_size_.height,
0.0f, // 0m min 0.0f, // 0m min
15.0f, // 15m max 15.0f, // 15m max
1.0 / calib_->getQ().at<double>(3,2), // Baseline 1.0 / calib_->getQ().at<double>(3,2), // Baseline
......
...@@ -17,9 +17,7 @@ class Disparity; ...@@ -17,9 +17,7 @@ class Disparity;
/** /**
* RGBD source from either a stereo video file with left + right images, or * RGBD source from either a stereo video file with left + right images, or
* direct from two camera devices. A variety of algorithms are included for * direct from two camera devices.
* calculating disparity, before converting to depth. Calibration of the images
* is also performed.
*/ */
class StereoVideoSource : public detail::Source { class StereoVideoSource : public detail::Source {
public: public:
...@@ -32,7 +30,7 @@ class StereoVideoSource : public detail::Source { ...@@ -32,7 +30,7 @@ class StereoVideoSource : public detail::Source {
bool retrieve(); bool retrieve();
bool compute(int n, int b); bool compute(int n, int b);
bool isReady(); bool isReady();
Camera parameters(ftl::codecs::Channel chan); Camera parameters(ftl::codecs::Channel chan) override;
private: private:
LocalSource *lsrc_; LocalSource *lsrc_;
......
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