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

set default values for intrinsics if no file

parent c004b20a
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,6 @@ StereoVideoSource::~StereoVideoSource() { ...@@ -50,7 +50,6 @@ StereoVideoSource::~StereoVideoSource() {
void StereoVideoSource::init(const string &file) { void StereoVideoSource::init(const string &file) {
capabilities_ = kCapVideo | kCapStereo; capabilities_ = kCapVideo | kCapStereo;
calibrated_ = false;
if (ftl::is_video(file)) { if (ftl::is_video(file)) {
// Load video file // Load video file
...@@ -94,7 +93,6 @@ void StereoVideoSource::init(const string &file) { ...@@ -94,7 +93,6 @@ void StereoVideoSource::init(const string &file) {
if (calib_->loadCalibration(fname)) { if (calib_->loadCalibration(fname)) {
calib_->calculateRectificationParameters(); calib_->calculateRectificationParameters();
calib_->setRectify(true); calib_->setRectify(true);
calibrated_ = true;
} }
} }
else { else {
...@@ -103,6 +101,16 @@ void StereoVideoSource::init(const string &file) { ...@@ -103,6 +101,16 @@ void StereoVideoSource::init(const string &file) {
+ std::string("calibration.yml"); + std::string("calibration.yml");
LOG(ERROR) << "No calibration, default path set to " + fname; LOG(ERROR) << "No calibration, default path set to " + fname;
// set use config file/set (some) default values
cv::Mat K = cv::Mat::eye(cv::Size(3, 3), CV_64FC1);
K.at<double>(0,0) = host_->value("focal", 500.0);
K.at<double>(1,1) = host_->value("focal", 500.0);
K.at<double>(0,2) = host_->value("centre_x", -color_size_.width/2.0f);
K.at<double>(1,2) = host_->value("centre_y", -color_size_.height/2.0f);
calib_->setIntrinsics(color_size_, {K, K});
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
...@@ -135,8 +143,6 @@ void StereoVideoSource::init(const string &file) { ...@@ -135,8 +143,6 @@ void StereoVideoSource::init(const string &file) {
} }
} }
calibrated_ = true; // Means we have intrinsics
return true; return true;
}); });
...@@ -200,43 +206,27 @@ void StereoVideoSource::updateParameters() { ...@@ -200,43 +206,27 @@ void StereoVideoSource::updateParameters() {
float max_depth = this->host_->getConfig().value<double>("max_depth", 15.0); float max_depth = this->host_->getConfig().value<double>("max_depth", 15.0);
// left // left
// FIXME: Check this change doesn't break anything (adding of calibrated_) K = calib_->getCameraMatrixLeft(color_size_);
if (calibrated_) { state_.getLeft() = {
K = calib_->getCameraMatrixLeft(color_size_); static_cast<float>(K.at<double>(0,0)), // Fx
state_.getLeft() = { static_cast<float>(K.at<double>(1,1)), // Fy
static_cast<float>(K.at<double>(0,0)), // Fx static_cast<float>(-K.at<double>(0,2)), // Cx
static_cast<float>(K.at<double>(1,1)), // Fy static_cast<float>(-K.at<double>(1,2)), // Cy
static_cast<float>(-K.at<double>(0,2)), // Cx (unsigned int) color_size_.width,
static_cast<float>(-K.at<double>(1,2)), // Cy (unsigned int) color_size_.height,
(unsigned int) color_size_.width, min_depth,
(unsigned int) color_size_.height, max_depth,
min_depth, baseline,
max_depth, doff
baseline, };
doff
}; host_->getConfig()["focal"] = params_.fx;
host_->getConfig()["centre_x"] = params_.cx;
host_->getConfig()["focal"] = params_.fx; host_->getConfig()["centre_y"] = params_.cy;
host_->getConfig()["centre_x"] = params_.cx; host_->getConfig()["baseline"] = params_.baseline;
host_->getConfig()["centre_y"] = params_.cy; host_->getConfig()["doffs"] = params_.doffs;
host_->getConfig()["baseline"] = params_.baseline;
host_->getConfig()["doffs"] = params_.doffs;
} else {
state_.getLeft() = {
host_->value("focal", 500.0f), // Fx
host_->value("focal", 500.0f), // Fy
host_->value("centre_x", -color_size_.width/2.0f), // Cx
host_->value("centre_y", -color_size_.height/2.0f), // Cy
(unsigned int) color_size_.width,
(unsigned int) color_size_.height,
min_depth,
max_depth,
baseline,
doff
};
}
// right // right
K = calib_->getCameraMatrixRight(color_size_); K = calib_->getCameraMatrixRight(color_size_);
......
...@@ -38,7 +38,6 @@ class StereoVideoSource : public detail::Source { ...@@ -38,7 +38,6 @@ class StereoVideoSource : public detail::Source {
LocalSource *lsrc_; LocalSource *lsrc_;
Calibrate *calib_; Calibrate *calib_;
bool calibrated_;
cv::Size color_size_; cv::Size color_size_;
cv::Size depth_size_; cv::Size depth_size_;
......
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