14#include <opencv2/opencv.hpp>
23 static bool fileExists(
const std::string& path);
25 static std::vector<std::string>
findFiles(
const std::string& directory,
26 const std::string& pattern);
30 static std::vector<std::string>
split(
const std::string& str,
char delimiter);
38 std::vector<std::string>& cam1Frames,
39 std::vector<std::string>& cam2Frames,
48 std::vector<std::string>& cam1Frames,
49 std::vector<std::string>& cam2Frames,
56 std::string& roiJsonPath,
57 std::string& roiMaskImagePath);
62 std::string& seedJsonPath);
88 const CameraParameters& params,
89 std::vector<cv::Point2d>& points_out);
95 const CameraParameters& params);
109 std::vector<double>& L);
118 t(Eigen::Vector3d::Zero()),
133 const std::vector<Eigen::Vector3d>& points_to,
134 RigidTransform& transform);
140 static std::vector<Eigen::Vector3d>
applyRigidTransform(
const std::vector<Eigen::Vector3d>& points_in,
141 const RigidTransform& transform);
152 static void setCameraPairs(
const std::vector<std::pair<int,int>>& camera_pairs);
155 static const std::vector<std::pair<int,int>>&
cameraPairs();
173 static void getCamerasForPair(
int stereopair,
const std::vector<std::pair<int,int>>& camera_pairs,
174 int& cam_first,
int& cam_second);
184 static std::string
buildBaseDataPath(
const Config& config,
bool with_data_or_dic_path =
false,
bool with_rawdata =
false,
bool with_speckles =
false);
215 static std::string
buildPath(
const Config& config,
bool with_data_or_dic_path =
false,
bool with_rawdata =
false,
bool with_speckles =
false,
bool with_material =
false,
bool with_video =
false,
bool with_protocol =
false,
bool with_calib =
false);
243 static std::string
buildProtocolDir(
const Config& config,
bool with_data_or_dic_path =
false,
bool with_rawdata =
false,
bool with_speckles =
false,
bool with_material =
false);
255 static std::string
buildVideoDir(
const Config& config,
bool with_data_or_dic_path =
false,
bool with_rawdata =
false,
bool with_speckles =
false,
bool with_material =
false);
273 static std::string
buildPath(
const cppxdic::BaseParameters& parameters,
bool with_material =
false,
bool with_trial =
false,
bool with_phase =
false,
bool with_cache =
false);
289 static std::string
likeRoiOrSeedPath(
const std::string& path,
const std::string_view& prefix,
const std::string& reftrial,
const std::string& phase,
int stereopair,
const std::string& extension);
290 static std::string
likeRoiPath(
const std::string& path,
const std::string& reftrial,
const std::string& phase,
int stereopair,
const std::string& extension);
291 static std::string
likeSeedPath(
const std::string& path,
const std::string& reftrial,
const std::string& phase,
int stereopair,
const std::string& extension);
325 static std::string
buildDic3DPPresultsFilePath(
const std::string pathdir,
int num_pair,
const std::string& fileversion,
const std::string& ext);
326 static std::string
buildVizPath(
const std::string pathdir,
const std::string filename);
328 static std::string
buildNcorrFilePath(
const std::string pathdir,
int cam_1,
int cam_2 = -1,
const std::string& extension =
".bin");
331 static bool checkROIReferences(
const Config& config);
332 static bool checkSeedReferences(
const Config& config);
333 static bool checkProtocolFiles(
const Config& config);
334 static bool checkCalibrationFiles(
const Config& config);
336 static std::string buildRoiOrSeedLikeFilePath(
const cppxdic::BaseParameters& parameters, std::string reftrial,
int stereopair, std::string_view prefix,
const std::string& extension =
".mat");
Utility functions for CPPXDIC Equivalent to various utility functions in Matlab xDIC.
static cv::Point2d undistortPoint(const cv::Point2d &point_in, const CameraParameters ¶ms)
Undistort single 2D point.
static std::string buildNcorrFilePath(const std::string pathdir, int cam_1, int cam_2=-1, const std::string &extension=".bin")
static std::string buildVideoDir(const Config &config, bool with_data_or_dic_path=false, bool with_rawdata=false, bool with_speckles=false, bool with_material=false)
Build the video path.
static void setCameraPairs(const std::vector< std::pair< int, int > > &camera_pairs)
Register the process-wide stereopair -> (cam_first, cam_second) table.
static std::string likeRoiPath(const std::string &path, const std::string &reftrial, const std::string &phase, int stereopair, const std::string &extension)
static bool fileExists(const std::string &path)
static bool importRawVid(const Config &config, int trial, int stereopair, int frameStart, int frameEnd, int frameJump, std::vector< std::string > &cam1Frames, std::vector< std::string > &cam2Frames, int maxFrames=0)
static std::string formatString(const std::string &format,...)
static std::string buildPath(const Config &config, bool with_data_or_dic_path=false, bool with_rawdata=false, bool with_speckles=false, bool with_material=false, bool with_video=false, bool with_protocol=false, bool with_calib=false)
Build the path based on activated parameters and return the proper string.
static std::string likeSeedPath(const std::string &path, const std::string &reftrial, const std::string &phase, int stereopair, const std::string &extension)
static std::string buildOutputCachePath(const cppxdic::BaseParameters ¶meters)
Build the output cache path.
static std::string buildBaseDataPath(const Config &config, bool with_data_or_dic_path=false, bool with_rawdata=false, bool with_speckles=false)
Build base data path.
static std::vector< std::string > split(const std::string &str, char delimiter)
static std::vector< std::string > findFiles(const std::string &directory, const std::string &pattern)
static std::string likeRoiOrSeedPath(const std::string &path, const std::string_view &prefix, const std::string &reftrial, const std::string &phase, int stereopair, const std::string &extension)
static std::string buildDic3DPPresultsFilePath(const std::string pathdir, int num_pair, const std::string &fileversion, const std::string &ext)
static std::string buildDic2DPairResultsFilePath(const std::string pathdir, int cam_1, int cam_2, const std::string &extension)
static std::string buildProtocolDir(const Config &config, bool with_data_or_dic_path=false, bool with_rawdata=false, bool with_speckles=false, bool with_material=false)
Build protocol path.
static std::string buildRoiFilePath(const cppxdic::BaseParameters ¶meters, std::string reftrial, int stereopair, const std::string &extension=".mat")
Build the roi file path.
static bool importVid(const Config &config, int trial, int stereopair, std::vector< std::string > &cam1Frames, std::vector< std::string > &cam2Frames, int maxFrames=0)
static std::string buildSeedFilePath(const cppxdic::BaseParameters ¶meters, std::string reftrial, int stereopair, const std::string &extension=".mat")
Build the seed file path.
static std::string buildCalibDir(const Config &config)
Build the calib path.
static bool dicCheck(const Config &config)
Utility functions implementation for CPPXDIC.
static std::string buildVizPath(const std::string pathdir, const std::string filename)
static void undistortPoints(const std::vector< cv::Point2d > &points_in, const CameraParameters ¶ms, std::vector< cv::Point2d > &points_out)
Undistort 2D points using camera parameters Matches MATLAB: undistortPoints(points,...
static bool computeRigidTransform(const std::vector< Eigen::Vector3d > &points_from, const std::vector< Eigen::Vector3d > &points_to, RigidTransform &transform)
Compute optimal rigid body transformation between two point clouds Matches MATLAB: rigidTransformatio...
static bool DLT11Calibration(const double *P2, const double *P3, size_t N, std::vector< double > &L)
Compute DLT (Direct Linear Transformation) 11 parameters from 2D-3D point correspondences Matches MAT...
static std::string buildOutputUntilPhaseDir(const Config &config, int trial)
Build output dir until the Phase folder.
static const std::vector< std::pair< int, int > > & cameraPairs()
Currently registered stereopair table (see setCameraPairs).
static std::string buildOutputUntilMaterialDir(const Config &config)
Build output path until material folder.
static std::string buildOutputUntilTrialDir(const Config &config, int trial)
Build output dir until Trial folder.
static std::vector< Eigen::Vector3d > applyRigidTransform(const std::vector< Eigen::Vector3d > &points_in, const RigidTransform &transform)
Apply rigid transformation to point cloud points_out = R * points_in + t.
static std::string buildMatchingFilePath(const cppxdic::BaseParameters ¶meters, std::string reftrial, int stereopair, const std::string &extension=".bin")
Build the matching file path.
static std::string buildUntilMaterialDir(const Config &config, bool with_data_or_dic_path, bool with_rawdata, bool with_speckles)
Build path until material folder.
static bool directoryExists(const std::string &path)
static bool loadROIFromMat(const Config &config, int trial, int stereopair, std::string &roiJsonPath, std::string &roiMaskImagePath)
static bool loadCameraParameters(const std::string &mat_path, CameraParameters ¶ms)
Load camera calibration parameters from MATLAB .mat file Matches MATLAB: load('cameraCBparameters_cam...
static std::string buildOutputPath(const cppxdic::BaseParameters ¶meters)
Build the output path.
static bool loadSeedFromMat(const Config &config, int trial, int stereopair, std::string &seedJsonPath)
static std::string buildDic3DCombinedFilePath(const std::string pathdir, int num_pair, const std::string &ext)
static void getCamerasForPair(int stereopair, int &cam_first, int &cam_second)
Get camera numbers for a given stereopair using the registered table (setCameraPairs).
cv::Mat distortion_coeffs
Base parameters structure Contains fundamental paths and settings for DIC analysis Equivalent to base...