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

RPC: set_intrinsics

parent 752c01c4
No related branches found
No related tags found
No related merge requests found
Pipeline #18436 passed
......@@ -126,7 +126,6 @@ bool setRectifyRPC(ftl::net::Universe* net, ftl::stream::Net* nstream, bool enab
bool setIntrinsicsRPC(ftl::net::Universe* net, ftl::stream::Net* nstream, Size size, vector<Mat> K, vector<Mat> D) {
Mat K0 = K[0].t();
Mat K1 = K[1].t();
return net->call<bool>( nstream->getPeer(), "set_intrinsics",
vector<int>{size.width, size.height},
vector<double>(K0.begin<double>(), K0.end<double>()),
......@@ -208,19 +207,19 @@ void calibrateRPC( ftl::net::Universe* net,
auto *nstream = nstreams[c/2];
while(true) {
try {
/*setIntrinsicsRPC(net, nstream,
setIntrinsicsRPC(net, nstream,
params.size,
vector<Mat>{calib.getCameraMat(c), calib.getCameraMat(c+1)},
vector<Mat>{calib.getDistCoeffs(c), calib.getDistCoeffs(c+1)}
);*/
);
setExtrinsicsRPC(net, nstream, R_c1c2, T_c1c2);
setPoseRPC(net, nstream, Rt_out[c]);
saveCalibrationRPC(net, nstream);
LOG(INFO) << "CALIBRATION SENT";
break;
}
catch (...) {
LOG(ERROR) << "RPC failed!";
catch (std::exception ex) {
LOG(ERROR) << "RPC failed: " << ex.what();
sleep(1);
}
}
......@@ -315,15 +314,18 @@ void runCameraCalibration( ftl::Configurable* root,
}
for (auto *nstream: nstreams) {
bool res = false;
try { res = setRectifyRPC(net, nstream, false); }
catch (...) {}
if (!res) {
LOG(ERROR) << "set_rectify() failed for " << *(nstream->get<string>("uri"));
}
else {
LOG(INFO) << "rectification disabled for " << *(nstream->get<string>("uri"));
bool res = true;
while(res) {
try { res = setRectifyRPC(net, nstream, false); }
catch (...) {}
if (res) {
LOG(ERROR) << "set_rectify() failed for " << *(nstream->get<string>("uri"));
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
else {
LOG(INFO) << "rectification disabled for " << *(nstream->get<string>("uri"));
}
}
}
......
......@@ -123,8 +123,8 @@ void StereoVideoSource::init(const string &file) {
host_->getNet()->bind("set_intrinsics",
[this]( std::vector<int> size,
std::vector<double> camera_l, std::vector<double> d_left,
std::vector<double> camera_r, std::vector<double> d_right) {
std::vector<double> camera_l, std::vector<double> dist_l,
std::vector<double> camera_r, std::vector<double> dist_r) {
if ((size.size() != 2) || (camera_l.size() != 9) || (camera_r.size() != 9)) {
LOG(ERROR) << "bad intrinsic parameters (wrong size)";
return false;
......@@ -132,8 +132,8 @@ void StereoVideoSource::init(const string &file) {
cv::Size calib_size(size[0], size[1]);
cv::Mat K_l = cv::Mat(camera_l).reshape(1, 3).t();
cv::Mat K_r = cv::Mat(camera_r).reshape(1, 3).t();
cv::Mat D_l = cv::Mat(D_l);
cv::Mat D_r = cv::Mat(D_r);
cv::Mat D_l = cv::Mat(dist_l);
cv::Mat D_r = cv::Mat(dist_r);
if (!calib_->setIntrinsics(calib_size, {K_l, K_r}, {D_l, D_r})) {
LOG(ERROR) << "bad intrinsic parameters (bad values)";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment