Skip to content

Commit

Permalink
boost::filesystem to std::filesystem (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
BAILOOL authored Sep 20, 2024
1 parent d8501be commit 4400397
Show file tree
Hide file tree
Showing 36 changed files with 217 additions and 165 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/checkout@v2 # required to mount the Github Workspace to a volume

- name: Run clang-format-lint
uses: DoozyX/clang-format-lint-action@v0.11
uses: DoozyX/clang-format-lint-action@v0.18.1
with:
source: '.'
exclude: './third_party ./external .git'
Expand Down
12 changes: 1 addition & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,9 @@ find_package(Ceres REQUIRED)
# boost related setup
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost COMPONENTS log system filesystem REQUIRED)
find_package(Boost COMPONENTS log system REQUIRED)
message(STATUS "Boost version: ${Boost_VERSION}")

# This is needed if your Boost version is newer than your CMake version
# or if you have an old version of CMake (<3.5)
if(NOT TARGET Boost::filesystem)
add_library(Boost::filesystem IMPORTED INTERFACE)
set_property(TARGET Boost::filesystem PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR})
set_property(TARGET Boost::filesystem PROPERTY
INTERFACE_LINK_LIBRARIES ${Boost_LIBRARIES})
endif()

IF(SSSE3_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse3")
ENDIF(SSSE3_FOUND)
Expand Down
2 changes: 1 addition & 1 deletion McCalib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ add_library(McCalib STATIC ${MC_CALIB_HEADERS} ${MC_CALIB_SOURCES})
set_target_properties(McCalib PROPERTIES VERSION ${PROJECT_VERSION})
target_include_directories(McCalib PUBLIC include)
target_include_directories(McCalib PUBLIC src)
target_link_libraries(McCalib PUBLIC -L/usr/local/lib ${OpenCV_LIBS} ${CERES_LIBRARIES} Boost::log Boost::system Boost::filesystem)
target_link_libraries(McCalib PUBLIC -L/usr/local/lib ${OpenCV_LIBS} ${CERES_LIBRARIES} Boost::log Boost::system)
6 changes: 4 additions & 2 deletions McCalib/include/Board.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#pragma once

#include "opencv2/core/core.hpp"
#include <filesystem>
#include <iostream>

#include "opencv2/core/core.hpp"
#include <opencv2/aruco/charuco.hpp>
#include <opencv2/opencv.hpp>
#include <stdio.h>
Expand Down Expand Up @@ -45,7 +47,7 @@ class Board final {
// Functions
Board() = delete;
~Board(){};
Board(const std::string config, const int board_idx);
Board(const std::filesystem::path &config, const int board_idx);
void insertNewBoard(std::shared_ptr<BoardObs> new_board);
void insertNewFrame(std::shared_ptr<Frame> new_frame);
};
11 changes: 7 additions & 4 deletions McCalib/include/Frame.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#pragma once

#include "opencv2/core/core.hpp"
#include <filesystem>
#include <iostream>
#include <stdio.h>

#include "opencv2/core/core.hpp"
#include <opencv2/aruco/charuco.hpp>
#include <opencv2/opencv.hpp>
#include <stdio.h>

#include "BoardObs.hpp"
#include "CameraGroupObs.hpp"
Expand Down Expand Up @@ -44,12 +46,13 @@ class Frame final {
cam_group_observations_; // cam group stored

// Image
std::map<int, std::string> frame_path_; // camera_id // path
std::map<int, std::filesystem::path> frame_path_; // camera_id // path

// Functions
Frame() = delete;
~Frame(){};
Frame(const int frame_idx, const int cam_idx, const std::string frame_path);
Frame(const int frame_idx, const int cam_idx,
const std::filesystem::path &frame_path);
void insertNewBoard(std::shared_ptr<BoardObs> newBoard);
void insertNewCamObs(std::shared_ptr<CameraObs> newCamObs);
void insertNewObject(std::shared_ptr<Object3DObs> new_object);
Expand Down
39 changes: 21 additions & 18 deletions McCalib/include/McCalib.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#pragma once

#include "boost/filesystem.hpp"
#include "opencv2/core/core.hpp"
#include <filesystem>
#include <iostream>
#include <mutex>
#include <numeric>
#include <stdio.h>

#include "opencv2/core/core.hpp"
#include <opencv2/aruco/charuco.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/opencv.hpp>
#include <stdio.h>

#include "Board.hpp"
#include "BoardObs.hpp"
Expand Down Expand Up @@ -43,14 +44,17 @@ class Calibration final {
float min_perc_pts_;

// images path
std::string root_dir_, cam_prefix_;
std::filesystem::path root_path_;
std::string cam_prefix_;

// intput/output path
std::string cam_params_path_; // path to precalibrated cameras intrinsics
std::string keypoints_path_; // path to predetected keypoints
std::string save_path_; // path to save calibrated cameras parameter
std::string camera_params_file_name_; // file name with cameras params
int save_repro_, save_detect_; // flag to save or not the images
std::filesystem::path
cam_params_path_; // path to precalibrated cameras intrinsics
std::filesystem::path keypoints_path_; // path to predetected keypoints
std::filesystem::path save_path_; // path to save calibrated cameras parameter
std::filesystem::path
camera_params_file_name_; // file name with cameras params
int save_repro_, save_detect_; // flag to save or not the images

// various boards size parameters
std::vector<int> number_x_square_per_board_, number_y_square_per_board_;
Expand Down Expand Up @@ -141,9 +145,9 @@ class Calibration final {
// Functions
Calibration() = delete;
~Calibration(){};
Calibration(
const std::string config_path); // initialize the charuco pattern, nb
// of cameras, nb of boards etc.
Calibration(const std::filesystem::path
&config_path); // initialize the charuco pattern, nb
// of cameras, nb of boards etc.
Calibration(const Calibration &) = delete;
Calibration &operator=(const Calibration &) = delete;

Expand All @@ -160,12 +164,11 @@ class Calibration final {
// re-used to save time in detection stage
void displayBoards(const cv::Mat image, const int cam_idx,
const int frame_idx);
void
insertNewBoard(const int cam_idx, const int frame_idx, const int board_idx,
const std::vector<cv::Point2f> pts_2d,
const std::vector<int> charuco_idx,
const std::string frame_path); // insert a new board in all the
// different datastructure
void insertNewBoard(
const int cam_idx, const int frame_idx, const int board_idx,
const std::vector<cv::Point2f> pts_2d, const std::vector<int> charuco_idx,
const std::filesystem::path frame_path); // insert a new board in all the
// different datastructure
void
insertNewObjectObservation(std::shared_ptr<Object3DObs>
new_obj_obs); // insert new object observation
Expand Down
12 changes: 12 additions & 0 deletions McCalib/include/utilities.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

#include <filesystem>
#include <string>
#include <vector>

namespace McCalib {

std::filesystem::path convertStrToPath(const std::string &item_name);
std::vector<std::filesystem::path>
convertVecStrToVecPath(const std::vector<std::string> &input);

} // namespace McCalib
14 changes: 8 additions & 6 deletions McCalib/src/Board.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "boost/filesystem.hpp"
#include "opencv2/core/core.hpp"

#include <iostream>
#include <numeric>
#include <stdio.h>

#include "opencv2/core/core.hpp"
#include <opencv2/aruco/charuco.hpp>
#include <opencv2/opencv.hpp>
#include <stdio.h>

#include "Board.hpp"
#include "Frame.hpp"
Expand All @@ -16,14 +17,15 @@
* @param config_path path to the configuration file
* @param board_idx index of the board
*/
Board::Board(const std::string config_path, const int board_idx) {
Board::Board(const std::filesystem::path &config_path, const int board_idx) {
std::vector<int> number_x_square_per_board, number_y_square_per_board;
std::vector<double> square_size_per_board;
std::vector<int> boards_index;
int nb_board;
cv::FileStorage fs; // FileStorage object to read calibration params from file
const bool is_file_available =
boost::filesystem::exists(config_path) && config_path.length() > 0;
const bool is_file_available = std::filesystem::exists(config_path) &&
config_path.has_filename() &&
config_path.extension() == ".yml";
if (!is_file_available) {
LOG_FATAL << "Config path '" << config_path << "' doesn't exist.";
return;
Expand Down
7 changes: 4 additions & 3 deletions McCalib/src/Frame.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#include "opencv2/core/core.hpp"
#include <iostream>
#include <stdio.h>

#include "opencv2/core/core.hpp"
#include <opencv2/aruco/charuco.hpp>
#include <opencv2/opencv.hpp>
#include <stdio.h>

#include "Frame.hpp"

Frame::Frame(const int frame_idx, const int cam_idx,
const std::string frame_path) {
const std::filesystem::path &frame_path) {
frame_idx_ = frame_idx;
frame_path_[cam_idx] = frame_path;
}
Expand Down
Loading

0 comments on commit 4400397

Please sign in to comment.