fix(api): get_imu_correspondence
This commit is contained in:
parent
f4007aa78c
commit
ecb8cd640a
|
@ -55,76 +55,77 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
auto &&left_data = api->GetStreamData(Stream::LEFT);
|
||||||
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
auto &&right_data = api->GetStreamData(Stream::RIGHT);
|
||||||
if (left_data.frame.empty() || right_data.frame.empty()) {
|
if (!left_data.frame.empty() || !right_data.frame.empty()) {
|
||||||
continue;
|
auto img_stamp = left_data.img->timestamp;
|
||||||
}
|
LOG(INFO) << "Img timestamp: " << img_stamp
|
||||||
|
<< ", diff_prev=" << (img_stamp - prev_img_stamp);
|
||||||
|
prev_img_stamp = img_stamp;
|
||||||
|
|
||||||
auto img_stamp = left_data.img->timestamp;
|
cv::Mat img;
|
||||||
LOG(INFO) << "Img timestamp: " << img_stamp
|
cv::hconcat(left_data.frame, right_data.frame, img);
|
||||||
<< ", diff_prev=" << (img_stamp - prev_img_stamp);
|
|
||||||
prev_img_stamp = img_stamp;
|
|
||||||
|
|
||||||
cv::Mat img;
|
auto &&motion_datas = api->GetMotionDatas();
|
||||||
cv::hconcat(left_data.frame, right_data.frame, img);
|
LOG(INFO) << "Imu count: " << motion_datas.size();
|
||||||
|
if (motion_datas.size() == 0) {
|
||||||
auto &&motion_datas = api->GetMotionDatas();
|
continue;
|
||||||
LOG(INFO) << "Imu count: " << motion_datas.size();
|
|
||||||
for (size_t i = 0, n = motion_datas.size() - 1; i <= n; ++i) {
|
|
||||||
auto data = motion_datas[i];
|
|
||||||
auto imu_flag = data.imu->flag;
|
|
||||||
auto imu_stamp = data.imu->timestamp;
|
|
||||||
|
|
||||||
std::stringstream ss;
|
|
||||||
if (imu_flag == 0) { // accel + gyro
|
|
||||||
ss << "Imu";
|
|
||||||
} else if (imu_flag == 1) { // accel
|
|
||||||
ss << "Accel";
|
|
||||||
} else if (imu_flag == 2) { // gyro
|
|
||||||
ss << "Gyro";
|
|
||||||
}
|
}
|
||||||
ss << " timestamp: " << imu_stamp
|
for (size_t i = 0, n = motion_datas.size() - 1; i <= n; ++i) {
|
||||||
<< ", diff_prev=" << (imu_stamp - prev_imu_stamp)
|
auto data = motion_datas[i];
|
||||||
<< ", diff_img=" << (1.0f + imu_stamp - img_stamp);
|
auto imu_flag = data.imu->flag;
|
||||||
#ifdef CHECK_ACCEL_THEN_GYRO
|
auto imu_stamp = data.imu->timestamp;
|
||||||
if (imu_flag > 0) {
|
|
||||||
bool ok = false;
|
std::stringstream ss;
|
||||||
if (i == 0) { // first
|
if (imu_flag == 0) { // accel + gyro
|
||||||
ok = (imu_flag == SEQ_FIRST);
|
ss << "Imu";
|
||||||
} else if (i == n) { // last
|
} else if (imu_flag == 1) { // accel
|
||||||
ok = (imu_flag == SEQ_SECOND);
|
ss << "Accel";
|
||||||
} else {
|
} else if (imu_flag == 2) { // gyro
|
||||||
if (imu_flag == SEQ_FIRST) {
|
ss << "Gyro";
|
||||||
ok = (prev_imu_flag == SEQ_SECOND);
|
}
|
||||||
} else if (imu_flag == SEQ_SECOND) {
|
ss << " timestamp: " << imu_stamp
|
||||||
ok = (prev_imu_flag == SEQ_FIRST);
|
<< ", diff_prev=" << (imu_stamp - prev_imu_stamp)
|
||||||
|
<< ", diff_img=" << (1.0f + imu_stamp - img_stamp);
|
||||||
|
#ifdef CHECK_ACCEL_THEN_GYRO
|
||||||
|
if (imu_flag > 0) {
|
||||||
|
bool ok = false;
|
||||||
|
if (i == 0) { // first
|
||||||
|
ok = (imu_flag == SEQ_FIRST);
|
||||||
|
} else if (i == n) { // last
|
||||||
|
ok = (imu_flag == SEQ_SECOND);
|
||||||
|
} else {
|
||||||
|
if (imu_flag == SEQ_FIRST) {
|
||||||
|
ok = (prev_imu_flag == SEQ_SECOND);
|
||||||
|
} else if (imu_flag == SEQ_SECOND) {
|
||||||
|
ok = (prev_imu_flag == SEQ_FIRST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ss << (ok ? " ✓" : " x");
|
||||||
|
if (!ok) ++imu_disorder_count;
|
||||||
|
prev_imu_flag = imu_flag;
|
||||||
|
if (!exit) {
|
||||||
|
if (!ok) exit = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ss << (ok ? " ✓" : " x");
|
#endif
|
||||||
if (!ok) ++imu_disorder_count;
|
LOG(INFO) << ss.str();
|
||||||
prev_imu_flag = imu_flag;
|
|
||||||
if (!exit) {
|
prev_imu_stamp = imu_stamp;
|
||||||
if (!ok) exit = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
LOG(INFO);
|
||||||
LOG(INFO) << ss.str();
|
#ifdef CHECK_ACCEL_THEN_GYRO
|
||||||
|
imu_count += motion_datas.size();
|
||||||
|
if (exit) break;
|
||||||
|
#endif
|
||||||
|
|
||||||
prev_imu_stamp = imu_stamp;
|
/*
|
||||||
|
painter.DrawImgData(img, *left_data.img);
|
||||||
|
if (!motion_datas.empty()) {
|
||||||
|
painter.DrawImuData(img, *motion_datas[0].imu);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
cv::imshow("frame", img);
|
||||||
}
|
}
|
||||||
LOG(INFO);
|
|
||||||
#ifdef CHECK_ACCEL_THEN_GYRO
|
|
||||||
imu_count += motion_datas.size();
|
|
||||||
if (exit) break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
painter.DrawImgData(img, *left_data.img);
|
|
||||||
if (!motion_datas.empty()) {
|
|
||||||
painter.DrawImuData(img, *motion_datas[0].imu);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
cv::imshow("frame", img);
|
|
||||||
|
|
||||||
char key = static_cast<char>(cv::waitKey(1));
|
char key = static_cast<char>(cv::waitKey(1));
|
||||||
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
if (key == 27 || key == 'q' || key == 'Q') { // ESC/Q
|
||||||
|
|
Loading…
Reference in New Issue
Block a user