Fix t as right to left

This commit is contained in:
John Zhao 2018-07-22 10:42:15 +08:00
parent 087ef28da1
commit 54165b1acb
8 changed files with 26 additions and 26 deletions

View File

@ -25,8 +25,8 @@ int main(int argc, char *argv[]) {
LOG(INFO) << "Intrinsics left: {" << api->GetIntrinsics(Stream::LEFT) << "}"; LOG(INFO) << "Intrinsics left: {" << api->GetIntrinsics(Stream::LEFT) << "}";
LOG(INFO) << "Intrinsics right: {" << api->GetIntrinsics(Stream::RIGHT) LOG(INFO) << "Intrinsics right: {" << api->GetIntrinsics(Stream::RIGHT)
<< "}"; << "}";
LOG(INFO) << "Extrinsics left to right: {" LOG(INFO) << "Extrinsics right to left: {"
<< api->GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}"; << api->GetExtrinsics(Stream::RIGHT, Stream::LEFT) << "}";
return 0; return 0;
} }

View File

@ -213,11 +213,11 @@ std::vector<std::string> get_plugin_paths() {
API::API(std::shared_ptr<Device> device) : device_(device) { API::API(std::shared_ptr<Device> device) : device_(device) {
VLOG(2) << __func__; VLOG(2) << __func__;
if (std::dynamic_pointer_cast<StandardDevice>(device_) != nullptr) { if (std::dynamic_pointer_cast<StandardDevice>(device_) != nullptr) {
bool in_l_ok, in_r_ok, ex_l2r_ok; bool in_l_ok, in_r_ok, ex_r2l_ok;
device_->GetIntrinsics(Stream::LEFT, &in_l_ok); device_->GetIntrinsics(Stream::LEFT, &in_l_ok);
device_->GetIntrinsics(Stream::RIGHT, &in_r_ok); device_->GetIntrinsics(Stream::RIGHT, &in_r_ok);
device_->GetExtrinsics(Stream::LEFT, Stream::RIGHT, &ex_l2r_ok); device_->GetExtrinsics(Stream::RIGHT, Stream::LEFT, &ex_r2l_ok);
if (!in_l_ok || !in_r_ok || !ex_l2r_ok) { if (!in_l_ok || !in_r_ok || !ex_r2l_ok) {
#if defined(WITH_DEVICE_INFO_REQUIRED) #if defined(WITH_DEVICE_INFO_REQUIRED)
LOG(FATAL) LOG(FATAL)
#else #else

View File

@ -30,7 +30,7 @@ RectifyProcessor::RectifyProcessor(
VLOG(2) << __func__ << ": proc_period=" << proc_period; VLOG(2) << __func__ << ": proc_period=" << proc_period;
InitParams( InitParams(
device->GetIntrinsics(Stream::LEFT), device->GetIntrinsics(Stream::RIGHT), device->GetIntrinsics(Stream::LEFT), device->GetIntrinsics(Stream::RIGHT),
device->GetExtrinsics(Stream::LEFT, Stream::RIGHT)); device->GetExtrinsics(Stream::RIGHT, Stream::LEFT));
} }
RectifyProcessor::~RectifyProcessor() { RectifyProcessor::~RectifyProcessor() {
@ -56,7 +56,7 @@ bool RectifyProcessor::OnProcess(
} }
void RectifyProcessor::InitParams( void RectifyProcessor::InitParams(
Intrinsics in_left, Intrinsics in_right, Extrinsics ex_left_to_right) { Intrinsics in_left, Intrinsics in_right, Extrinsics ex_right_to_left) {
cv::Size size{in_left.width, in_left.height}; cv::Size size{in_left.width, in_left.height};
cv::Mat M1 = cv::Mat M1 =
@ -68,12 +68,12 @@ void RectifyProcessor::InitParams(
cv::Mat D1(1, 5, CV_64F, in_left.coeffs); cv::Mat D1(1, 5, CV_64F, in_left.coeffs);
cv::Mat D2(1, 5, CV_64F, in_right.coeffs); cv::Mat D2(1, 5, CV_64F, in_right.coeffs);
cv::Mat R = cv::Mat R =
(cv::Mat_<double>(3, 3) << ex_left_to_right.rotation[0][0], (cv::Mat_<double>(3, 3) << ex_right_to_left.rotation[0][0],
ex_left_to_right.rotation[0][1], ex_left_to_right.rotation[0][2], ex_right_to_left.rotation[0][1], ex_right_to_left.rotation[0][2],
ex_left_to_right.rotation[1][0], ex_left_to_right.rotation[1][1], ex_right_to_left.rotation[1][0], ex_right_to_left.rotation[1][1],
ex_left_to_right.rotation[1][2], ex_left_to_right.rotation[2][0], ex_right_to_left.rotation[1][2], ex_right_to_left.rotation[2][0],
ex_left_to_right.rotation[2][1], ex_left_to_right.rotation[2][2]); ex_right_to_left.rotation[2][1], ex_right_to_left.rotation[2][2]);
cv::Mat T(3, 1, CV_64F, ex_left_to_right.translation); cv::Mat T(3, 1, CV_64F, ex_right_to_left.translation);
VLOG(2) << "InitParams size: " << size; VLOG(2) << "InitParams size: " << size;
VLOG(2) << "M1: " << M1; VLOG(2) << "M1: " << M1;

View File

@ -47,7 +47,7 @@ class RectifyProcessor : public Processor {
private: private:
void InitParams( void InitParams(
Intrinsics in_left, Intrinsics in_right, Extrinsics ex_left_to_right); Intrinsics in_left, Intrinsics in_right, Extrinsics ex_right_to_left);
}; };
MYNTEYE_END_NAMESPACE MYNTEYE_END_NAMESPACE

View File

@ -565,11 +565,11 @@ void Device::ReadAllInfos() {
if (img_params.ok) { if (img_params.ok) {
SetIntrinsics(Stream::LEFT, img_params.in_left); SetIntrinsics(Stream::LEFT, img_params.in_left);
SetIntrinsics(Stream::RIGHT, img_params.in_right); SetIntrinsics(Stream::RIGHT, img_params.in_right);
SetExtrinsics(Stream::LEFT, Stream::RIGHT, img_params.ex_left_to_right); SetExtrinsics(Stream::RIGHT, Stream::LEFT, img_params.ex_right_to_left);
VLOG(2) << "Intrinsics left: {" << GetIntrinsics(Stream::LEFT) << "}"; VLOG(2) << "Intrinsics left: {" << GetIntrinsics(Stream::LEFT) << "}";
VLOG(2) << "Intrinsics right: {" << GetIntrinsics(Stream::RIGHT) << "}"; VLOG(2) << "Intrinsics right: {" << GetIntrinsics(Stream::RIGHT) << "}";
VLOG(2) << "Extrinsics left to right: {" VLOG(2) << "Extrinsics right to left: {"
<< GetExtrinsics(Stream::LEFT, Stream::RIGHT) << "}"; << GetExtrinsics(Stream::RIGHT, Stream::LEFT) << "}";
} else { } else {
LOG(WARNING) << "Intrinsics & extrinsics not exist"; LOG(WARNING) << "Intrinsics & extrinsics not exist";
} }

View File

@ -515,7 +515,7 @@ std::size_t from_data(
std::size_t i = 0; std::size_t i = 0;
i += from_data(&img_params->in_left, data + i, spec_version); i += from_data(&img_params->in_left, data + i, spec_version);
i += from_data(&img_params->in_right, data + i, spec_version); i += from_data(&img_params->in_right, data + i, spec_version);
i += from_data(&img_params->ex_left_to_right, data + i, spec_version); i += from_data(&img_params->ex_right_to_left, data + i, spec_version);
return i; return i;
} }
@ -787,7 +787,7 @@ std::size_t to_data(
std::size_t i = 3; // skip id, size std::size_t i = 3; // skip id, size
i += to_data(&img_params->in_left, data + i, spec_version); i += to_data(&img_params->in_left, data + i, spec_version);
i += to_data(&img_params->in_right, data + i, spec_version); i += to_data(&img_params->in_right, data + i, spec_version);
i += to_data(&img_params->ex_left_to_right, data + i, spec_version); i += to_data(&img_params->ex_right_to_left, data + i, spec_version);
// others // others
std::size_t size = i - 3; std::size_t size = i - 3;
data[0] = Channels::FID_IMG_PARAMS; data[0] = Channels::FID_IMG_PARAMS;

View File

@ -72,7 +72,7 @@ class MYNTEYE_API Channels {
bool ok; bool ok;
Intrinsics in_left; Intrinsics in_left;
Intrinsics in_right; Intrinsics in_right;
Extrinsics ex_left_to_right; Extrinsics ex_right_to_left;
} img_params_t; } img_params_t;
typedef struct ImuParams { typedef struct ImuParams {

View File

@ -72,7 +72,7 @@ bool DeviceWriter::WriteImgParams(const img_params_t &params) {
LOG(INFO) << "Write img params success"; LOG(INFO) << "Write img params success";
LOG(INFO) << "Intrinsics left: {" << params.in_left << "}"; LOG(INFO) << "Intrinsics left: {" << params.in_left << "}";
LOG(INFO) << "Intrinsics right: {" << params.in_right << "}"; LOG(INFO) << "Intrinsics right: {" << params.in_right << "}";
LOG(INFO) << "Extrinsics left to right: {" << params.ex_left_to_right LOG(INFO) << "Extrinsics right to left: {" << params.ex_right_to_left
<< "}"; << "}";
return true; return true;
} else { } else {
@ -185,8 +185,8 @@ bool DeviceWriter::SaveImgParams(
return false; return false;
} }
fs << "in_left" << std::vector<Intrinsics>{params.in_left} << "in_right" fs << "in_left" << std::vector<Intrinsics>{params.in_left} << "in_right"
<< std::vector<Intrinsics>{params.in_right} << "ex_left_to_right" << std::vector<Intrinsics>{params.in_right} << "ex_right_to_left"
<< params.ex_left_to_right; << params.ex_right_to_left;
fs.release(); fs.release();
return true; return true;
} }
@ -213,7 +213,7 @@ void DeviceWriter::SaveAllInfos(const std::string &dir) {
SaveImgParams( SaveImgParams(
{false, device_->GetIntrinsics(Stream::LEFT), {false, device_->GetIntrinsics(Stream::LEFT),
device_->GetIntrinsics(Stream::RIGHT), device_->GetIntrinsics(Stream::RIGHT),
device_->GetExtrinsics(Stream::LEFT, Stream::RIGHT)}, device_->GetExtrinsics(Stream::RIGHT, Stream::LEFT)},
dir + OS_SEP "img.params"); dir + OS_SEP "img.params");
auto &&m_in = device_->GetMotionIntrinsics(); auto &&m_in = device_->GetMotionIntrinsics();
SaveImuParams( SaveImuParams(
@ -348,11 +348,11 @@ DeviceWriter::img_params_t DeviceWriter::LoadImgParams(
to_intrinsics(w, h, m, M1, D1, &params.in_left); to_intrinsics(w, h, m, M1, D1, &params.in_left);
to_intrinsics(w, h, m, M2, D2, &params.in_right); to_intrinsics(w, h, m, M2, D2, &params.in_right);
to_extrinsics(R, T, &params.ex_left_to_right); to_extrinsics(R, T, &params.ex_right_to_left);
} else { } else {
fs["in_left"][0] >> params.in_left; fs["in_left"][0] >> params.in_left;
fs["in_right"][0] >> params.in_right; fs["in_right"][0] >> params.in_right;
fs["ex_left_to_right"] >> params.ex_left_to_right; fs["ex_right_to_left"] >> params.ex_right_to_left;
} }
fs.release(); fs.release();