/** BSD 3-Clause License This file is part of the Basalt project. https://gitlab.com/VladyslavUsenko/basalt.git Copyright (c) 2019, Vladyslav Usenko and Nikolaus Demmel. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace basalt { template class SplineOptimization; class CamImuCalib { public: CamImuCalib(const std::string &dataset_path, const std::string &dataset_type, const std::string &aprilgrid_path, const std::string &cache_path, const std::string &cache_dataset_name, int skip_images, const std::vector &imu_noise, bool show_gui = true); ~CamImuCalib(); void initGui(); void setNumCameras(size_t n); void renderingLoop(); void computeProjections(); void detectCorners(); void initCamPoses(); void initCamImuTransform(); void initOptimization(); void initMocap(); void loadDataset(); void optimize(); bool optimizeWithParam(bool print_info, std::map *stats = nullptr); void saveCalib(); void saveMocapCalib(); void drawImageOverlay(pangolin::View &v, size_t cam_id); void recomputeDataLog(); void drawPlots(); bool hasCorners() const; void setOptIntrinsics(bool opt) { opt_intr = opt; } private: static constexpr int UI_WIDTH = 300; VioDatasetPtr vio_dataset; CalibCornerMap calib_corners; CalibCornerMap calib_corners_rejected; CalibInitPoseMap calib_init_poses; std::shared_ptr processing_thread; std::shared_ptr> calib_opt; std::map reprojected_corners; std::string dataset_path; std::string dataset_type; AprilGrid april_grid; std::string cache_path; std::string cache_dataset_name; int skip_images; bool show_gui; const size_t MIN_CORNERS = 15; std::vector imu_noise; ////////////////////// pangolin::Var show_frame; pangolin::Var show_corners; pangolin::Var show_corners_rejected; pangolin::Var show_init_reproj; pangolin::Var show_opt; pangolin::Var show_ids; pangolin::Var show_accel; pangolin::Var show_gyro; pangolin::Var show_pos; pangolin::Var show_rot_error; pangolin::Var show_mocap; pangolin::Var show_mocap_rot_error; pangolin::Var show_mocap_rot_vel; pangolin::Var show_spline; pangolin::Var show_data; pangolin::Var opt_intr; pangolin::Var opt_poses; pangolin::Var opt_corners; pangolin::Var opt_cam_time_offset; pangolin::Var opt_imu_scale; pangolin::Var opt_mocap; pangolin::Var huber_thresh; pangolin::Var opt_until_convg; pangolin::Var stop_thresh; pangolin::Plotter *plotter; pangolin::View *img_view_display; std::vector> img_view; pangolin::DataLog imu_data_log, pose_data_log, mocap_data_log, vign_data_log; }; } // namespace basalt