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

camera parameters (#245)

parent 1fd0d7ca
No related branches found
No related tags found
No related merge requests found
...@@ -395,37 +395,6 @@ void runCameraCalibration( ftl::Configurable* root, ...@@ -395,37 +395,6 @@ void runCameraCalibration( ftl::Configurable* root,
const size_t n_cameras = n_sources * 2; const size_t n_cameras = n_sources * 2;
size_t reference_camera = 0; size_t reference_camera = 0;
{
auto camera = sources[0]->parameters();
params.size = Size(camera.width, camera.height);
LOG(INFO) << "Camera resolution: " << params.size;
}
params.idx_cameras.resize(n_cameras);
std::iota(params.idx_cameras.begin(), params.idx_cameras.end(), 0);
// TODO: parameter for calibration target type
auto calib = MultiCameraCalibrationNew( n_cameras, reference_camera,
params.size, CalibrationTarget(0.250)
);
for (size_t i = 0; i < n_sources; i++) {
auto camera_r = sources[i]->parameters(Channel::Right);
auto camera_l = sources[i]->parameters(Channel::Left);
CHECK(params.size == Size(camera_r.width, camera_r.height));
CHECK(params.size == Size(camera_l.width, camera_l.height));
Mat K;
K = createCameraMatrix(camera_r);
LOG(INFO) << "K[" << 2 * i + 1 << "] = \n" << K;
calib.setCameraParameters(2 * i + 1, K);
K = createCameraMatrix(camera_l);
LOG(INFO) << "K[" << 2 * i << "] = \n" << K;
calib.setCameraParameters(2 * i, K);
}
ftl::rgbd::Group group; ftl::rgbd::Group group;
for (Source* src : sources) { for (Source* src : sources) {
src->setChannel(Channel::Right); src->setChannel(Channel::Right);
...@@ -442,6 +411,8 @@ void runCameraCalibration( ftl::Configurable* root, ...@@ -442,6 +411,8 @@ void runCameraCalibration( ftl::Configurable* root,
mutex.lock(); mutex.lock();
bool good = true; bool good = true;
for (size_t i = 0; i < frames.sources.size(); i ++) { for (size_t i = 0; i < frames.sources.size(); i ++) {
frames.frames[i].download(Channel::Left+Channel::Right);
if (frames.frames[i].get<cv::Mat>(Channel::Left).empty()) good = false; if (frames.frames[i].get<cv::Mat>(Channel::Left).empty()) good = false;
if (frames.frames[i].get<cv::Mat>(Channel::Right).empty()) good = false; if (frames.frames[i].get<cv::Mat>(Channel::Right).empty()) good = false;
if (frames.frames[i].get<cv::Mat>(Channel::Left).channels() != 3) good = false; // ASSERT if (frames.frames[i].get<cv::Mat>(Channel::Left).channels() != 3) good = false; // ASSERT
...@@ -455,6 +426,43 @@ void runCameraCalibration( ftl::Configurable* root, ...@@ -455,6 +426,43 @@ void runCameraCalibration( ftl::Configurable* root,
mutex.unlock(); mutex.unlock();
return true; return true;
}); });
for (auto &source : sources) {
while (!source->isReady()) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}
{
auto camera = sources[0]->parameters();
params.size = Size(camera.width, camera.height);
LOG(INFO) << "Camera resolution: " << params.size;
}
params.idx_cameras.resize(n_cameras);
std::iota(params.idx_cameras.begin(), params.idx_cameras.end(), 0);
// TODO: parameter for calibration target type
auto calib = MultiCameraCalibrationNew( n_cameras, reference_camera,
params.size, CalibrationTarget(0.250)
);
for (size_t i = 0; i < n_sources; i++) {
auto camera_r = sources[i]->parameters(Channel::Right);
auto camera_l = sources[i]->parameters();
CHECK(params.size == Size(camera_r.width, camera_r.height));
CHECK(params.size == Size(camera_l.width, camera_l.height));
Mat K;
K = createCameraMatrix(camera_r);
LOG(INFO) << "K[" << 2 * i + 1 << "] = \n" << K;
calib.setCameraParameters(2 * i + 1, K);
K = createCameraMatrix(camera_l);
LOG(INFO) << "K[" << 2 * i << "] = \n" << K;
calib.setCameraParameters(2 * i, K);
}
int iter = 0; int iter = 0;
Mat show; Mat show;
......
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