diff --git a/doc/changes/aux/mr.266.4.md b/doc/changes/aux/mr.266.4.md new file mode 100644 index 000000000..089027a82 --- /dev/null +++ b/doc/changes/aux/mr.266.4.md @@ -0,0 +1 @@ +tracking: Remove all path hardcoded calibration data loading and saving functions. diff --git a/src/xrt/auxiliary/tracking/t_file.cpp b/src/xrt/auxiliary/tracking/t_file.cpp index aecf31c3b..7efaa7230 100644 --- a/src/xrt/auxiliary/tracking/t_file.cpp +++ b/src/xrt/auxiliary/tracking/t_file.cpp @@ -19,9 +19,6 @@ * */ -static int -mkpath(char *path); - static bool read_cv_mat(FILE *f, cv::Mat *m, const char *name); @@ -313,105 +310,12 @@ t_stereo_camera_calibration_save_v1(FILE *calib_file, } -/* - * - * Hack functions. - * - */ - -extern "C" bool -t_stereo_camera_calibration_load_v1_hack( - struct t_stereo_camera_calibration **out_data) -{ - const char *configuration_filename = "PS4_EYE"; - - char path_string[256]; //! @todo 256 maybe not enough - //! @todo Use multiple env vars? - char *config_path = secure_getenv("HOME"); - snprintf(path_string, 256, "%s/.config/monado/%s.calibration", - config_path, configuration_filename); //! @todo Hardcoded 256 - - FILE *calib_file = fopen(path_string, "rb"); - if (calib_file == NULL) { - return false; - } - - bool ret = t_stereo_camera_calibration_load_v1(calib_file, out_data); - - fclose(calib_file); - - return ret; -} - -extern "C" bool -t_stereo_camera_calibration_save_v1_hack( - struct t_stereo_camera_calibration *data) -{ - char path_string[PATH_MAX]; - char file_string[PATH_MAX]; - // TODO: centralise this - use multiple env vars? - char *config_path = secure_getenv("HOME"); - snprintf(path_string, PATH_MAX, "%s/.config/monado", config_path); - snprintf(file_string, PATH_MAX, "%s/.config/monado/%s.calibration", - config_path, "PS4_EYE"); - FILE *calib_file = fopen(file_string, "wb"); - if (!calib_file) { - // try creating it - mkpath(path_string); - } - calib_file = fopen(file_string, "wb"); - if (!calib_file) { - printf( - "ERROR. could not create calibration file " - "%s\n", - file_string); - return false; - } - - t_stereo_camera_calibration_save_v1(calib_file, data); - - fclose(calib_file); - - return true; -} - - /* * * Helpers * */ -//! @todo Move this as it is a generic helper -static int -mkpath(char *path) -{ - char tmp[PATH_MAX]; //!< @todo PATH_MAX probably not strictly correct - char *p = nullptr; - size_t len; - - snprintf(tmp, sizeof(tmp), "%s", path); - len = strlen(tmp) - 1; - if (tmp[len] == '/') { - tmp[len] = 0; - } - - for (p = tmp + 1; *p; p++) { - if (*p == '/') { - *p = 0; - if (mkdir(tmp, S_IRWXU) < 0 && errno != EEXIST) - return -1; - *p = '/'; - } - } - - if (mkdir(tmp, S_IRWXU) < 0 && errno != EEXIST) { - return -1; - } - - return 0; -} - static bool write_cv_mat(FILE *f, cv::Mat *m) { diff --git a/src/xrt/auxiliary/tracking/t_tracking.h b/src/xrt/auxiliary/tracking/t_tracking.h index 533e42032..81c3a77b4 100644 --- a/src/xrt/auxiliary/tracking/t_tracking.h +++ b/src/xrt/auxiliary/tracking/t_tracking.h @@ -178,13 +178,6 @@ bool t_stereo_camera_calibration_load_v1( FILE *calib_file, struct t_stereo_camera_calibration **out_data); -/*! - * Load a stereo calibration struct from a hardcoded place. - */ -bool -t_stereo_camera_calibration_load_v1_hack( - struct t_stereo_camera_calibration **out_data); - /*! * Save the given stereo calibration data to the given file. */ @@ -192,14 +185,6 @@ bool t_stereo_camera_calibration_save_v1(FILE *calib_file, struct t_stereo_camera_calibration *data); -/*! - * Save raw calibration data to file, hack until prober has storage for such - * things. - */ -bool -t_stereo_camera_calibration_save_v1_hack( - struct t_stereo_camera_calibration *data); - /* *