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() {
void StereoVideoSource::init(const string &file) {
capabilities_ = kCapVideo | kCapStereo;
calibrated_ = false;
if (ftl::is_video(file)) {
// Load video file
......@@ -94,7 +93,6 @@ void StereoVideoSource::init(const string &file) {
if (calib_->loadCalibration(fname)) {
calib_->calculateRectificationParameters();
calib_->setRectify(true);
calibrated_ = true;
}
}
else {
......@@ -103,6 +101,16 @@ void StereoVideoSource::init(const string &file) {
+ std::string("calibration.yml");
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) {
}
}
calibrated_ = true; // Means we have intrinsics
return true;
});
......@@ -201,8 +207,6 @@ void StereoVideoSource::updateParameters() {
// left
// FIXME: Check this change doesn't break anything (adding of calibrated_)
if (calibrated_) {
K = calib_->getCameraMatrixLeft(color_size_);
state_.getLeft() = {
static_cast<float>(K.at<double>(0,0)), // Fx
......@@ -222,20 +226,6 @@ void StereoVideoSource::updateParameters() {
host_->getConfig()["centre_y"] = params_.cy;
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
......
......@@ -38,7 +38,6 @@ class StereoVideoSource : public detail::Source {
LocalSource *lsrc_;
Calibrate *calib_;
bool calibrated_;
cv::Size color_size_;
cv::Size depth_size_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment