|
|
@@ -95,10 +95,6 @@ namespace camera_calibrator_impl {
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
- glm::vec3 to_translation(const glm::mat4 &mat) {
|
|
|
- return glm::column(mat, 3);
|
|
|
- }
|
|
|
-
|
|
|
void hand_eye_calib::set_object_points(cv::Size size, float dis) {
|
|
|
obj_ps.clear();
|
|
|
for (auto iy = 0; iy < size.height; ++iy)
|
|
|
@@ -108,28 +104,7 @@ namespace camera_calibrator_impl {
|
|
|
}
|
|
|
|
|
|
glm::mat4 hand_eye_calib::calc_track_mat(timestamp_type t) {
|
|
|
- auto iter = track_pool.lower_bound(t);
|
|
|
- assert(iter != track_pool.end());
|
|
|
- if (iter == track_pool.begin()
|
|
|
- || iter->first == t) { // do not need interpolation
|
|
|
- return iter->second;
|
|
|
- }
|
|
|
-
|
|
|
- auto next = iter, prev = --iter;
|
|
|
- assert(next != track_pool.begin());
|
|
|
- auto next_ts = next->first, prev_ts = prev->first;
|
|
|
- auto interp_t = 1.0f * (t - prev_ts) / (next_ts - prev_ts);
|
|
|
-
|
|
|
- auto next_mat = next->second, prev_mat = prev->second;
|
|
|
- auto next_t = to_translation(next_mat);
|
|
|
- auto prev_t = to_translation(prev_mat);
|
|
|
- auto cur_t = glm::mix(prev_t, next_t, interp_t);
|
|
|
-
|
|
|
- auto next_quat = glm::quat_cast(glm::mat3(next_mat));
|
|
|
- auto prev_quat = glm::quat_cast(glm::mat3(prev_mat));
|
|
|
- auto cur_quat = glm::slerp(prev_quat, next_quat, interp_t);
|
|
|
-
|
|
|
- return to_transform_mat(cur_t, glm::mat3_cast(cur_quat));
|
|
|
+ return track_pool.query(t);
|
|
|
}
|
|
|
|
|
|
glm::vec2 hand_eye_calib::distort_point(glm::vec2 p) {
|
|
|
@@ -405,9 +380,8 @@ void camera_calibrator::impl::process() {
|
|
|
});
|
|
|
std::ranges::copy(valid_imgs, std::back_inserter(calib->img_pool));
|
|
|
|
|
|
- // TODO: C++23 can done this by std::ranges::to
|
|
|
for (auto &item: track_pool) {
|
|
|
- calib->track_pool.emplace(item.sample_ts, item.ref_mat);
|
|
|
+ calib->track_pool.add(item.ref_mat, item.sample_ts);
|
|
|
}
|
|
|
|
|
|
calib->calc();
|
|
|
@@ -418,7 +392,10 @@ void camera_calibrator::impl::process() {
|
|
|
conf.sophiar_conn->update_transform_variable(
|
|
|
conf.result_transform_var, ret);
|
|
|
}
|
|
|
- conf.cb_func(calib->intrinsic_v0());
|
|
|
+ conf.cb_func(result_type{
|
|
|
+ .cam_in = calib->intrinsic_v0(),
|
|
|
+ .time_offset = calib->result_ts_offset,
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
void camera_calibrator::impl::simulate_process(const simulate_info_type &info) {
|
|
|
@@ -467,6 +444,7 @@ void camera_calibrator::impl::save_track_data() {
|
|
|
for (auto &point: item.corners) {
|
|
|
fout << point.x << " " << point.y << " ";
|
|
|
}
|
|
|
+ fout << item.corner_sharpness;
|
|
|
fout << std::endl;
|
|
|
}
|
|
|
fout << std::endl;
|
|
|
@@ -504,6 +482,7 @@ void camera_calibrator::impl::load_track_data(const std::string &path) {
|
|
|
auto &p = item.corners.emplace_back();
|
|
|
fin >> p.x >> p.y;
|
|
|
}
|
|
|
+ fin >> item.corner_sharpness;
|
|
|
item.corners_detected = true;
|
|
|
item.process_finished = true;
|
|
|
}
|