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 ...@@ -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) { bool setIntrinsicsRPC(ftl::net::Universe* net, ftl::stream::Net* nstream, Size size, vector<Mat> K, vector<Mat> D) {
Mat K0 = K[0].t(); Mat K0 = K[0].t();
Mat K1 = K[1].t(); Mat K1 = K[1].t();
return net->call<bool>( nstream->getPeer(), "set_intrinsics", return net->call<bool>( nstream->getPeer(), "set_intrinsics",
vector<int>{size.width, size.height}, vector<int>{size.width, size.height},
vector<double>(K0.begin<double>(), K0.end<double>()), vector<double>(K0.begin<double>(), K0.end<double>()),
...@@ -208,19 +207,19 @@ void calibrateRPC( ftl::net::Universe* net, ...@@ -208,19 +207,19 @@ void calibrateRPC( ftl::net::Universe* net,
auto *nstream = nstreams[c/2]; auto *nstream = nstreams[c/2];
while(true) { while(true) {
try { try {
/*setIntrinsicsRPC(net, nstream, setIntrinsicsRPC(net, nstream,
params.size, params.size,
vector<Mat>{calib.getCameraMat(c), calib.getCameraMat(c+1)}, vector<Mat>{calib.getCameraMat(c), calib.getCameraMat(c+1)},
vector<Mat>{calib.getDistCoeffs(c), calib.getDistCoeffs(c+1)} vector<Mat>{calib.getDistCoeffs(c), calib.getDistCoeffs(c+1)}
);*/ );
setExtrinsicsRPC(net, nstream, R_c1c2, T_c1c2); setExtrinsicsRPC(net, nstream, R_c1c2, T_c1c2);
setPoseRPC(net, nstream, Rt_out[c]); setPoseRPC(net, nstream, Rt_out[c]);
saveCalibrationRPC(net, nstream); saveCalibrationRPC(net, nstream);
LOG(INFO) << "CALIBRATION SENT"; LOG(INFO) << "CALIBRATION SENT";
break; break;
} }
catch (...) { catch (std::exception ex) {
LOG(ERROR) << "RPC failed!"; LOG(ERROR) << "RPC failed: " << ex.what();
sleep(1); sleep(1);
} }
} }
...@@ -315,15 +314,18 @@ void runCameraCalibration( ftl::Configurable* root, ...@@ -315,15 +314,18 @@ void runCameraCalibration( ftl::Configurable* root,
} }
for (auto *nstream: nstreams) { for (auto *nstream: nstreams) {
bool res = false; bool res = true;
try { res = setRectifyRPC(net, nstream, false); } while(res) {
catch (...) {} try { res = setRectifyRPC(net, nstream, false); }
catch (...) {}
if (!res) {
LOG(ERROR) << "set_rectify() failed for " << *(nstream->get<string>("uri")); if (res) {
} LOG(ERROR) << "set_rectify() failed for " << *(nstream->get<string>("uri"));
else { std::this_thread::sleep_for(std::chrono::milliseconds(100));
LOG(INFO) << "rectification disabled for " << *(nstream->get<string>("uri")); }
else {
LOG(INFO) << "rectification disabled for " << *(nstream->get<string>("uri"));
}
} }
} }
......
...@@ -123,8 +123,8 @@ void StereoVideoSource::init(const string &file) { ...@@ -123,8 +123,8 @@ void StereoVideoSource::init(const string &file) {
host_->getNet()->bind("set_intrinsics", host_->getNet()->bind("set_intrinsics",
[this]( std::vector<int> size, [this]( std::vector<int> size,
std::vector<double> camera_l, std::vector<double> d_left, std::vector<double> camera_l, std::vector<double> dist_l,
std::vector<double> camera_r, std::vector<double> d_right) { std::vector<double> camera_r, std::vector<double> dist_r) {
if ((size.size() != 2) || (camera_l.size() != 9) || (camera_r.size() != 9)) { if ((size.size() != 2) || (camera_l.size() != 9) || (camera_r.size() != 9)) {
LOG(ERROR) << "bad intrinsic parameters (wrong size)"; LOG(ERROR) << "bad intrinsic parameters (wrong size)";
return false; return false;
...@@ -132,8 +132,8 @@ void StereoVideoSource::init(const string &file) { ...@@ -132,8 +132,8 @@ void StereoVideoSource::init(const string &file) {
cv::Size calib_size(size[0], size[1]); cv::Size calib_size(size[0], size[1]);
cv::Mat K_l = cv::Mat(camera_l).reshape(1, 3).t(); 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 K_r = cv::Mat(camera_r).reshape(1, 3).t();
cv::Mat D_l = cv::Mat(D_l); cv::Mat D_l = cv::Mat(dist_l);
cv::Mat D_r = cv::Mat(D_r); cv::Mat D_r = cv::Mat(dist_r);
if (!calib_->setIntrinsics(calib_size, {K_l, K_r}, {D_l, D_r})) { if (!calib_->setIntrinsics(calib_size, {K_l, K_r}, {D_l, D_r})) {
LOG(ERROR) << "bad intrinsic parameters (bad values)"; LOG(ERROR) << "bad intrinsic parameters (bad values)";
......
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