Skip to content
Snippets Groups Projects
Commit dd3be93e authored by calrama's avatar calrama
Browse files

Throw exception if output file cannot be opened, try to create output file path.

parent ed00437b
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,8 @@ add_executable(camera_calibration ...@@ -8,6 +8,8 @@ add_executable(camera_calibration
src/main.cc src/main.cc
) )
set_property(TARGET camera_calibration PROPERTY CXX_STANDARD 17)
find_package(OpenCV 4 QUIET) find_package(OpenCV 4 QUIET)
if(NOT OpenCV_FOUND) if(NOT OpenCV_FOUND)
find_package(OpenCV 3 REQUIRED) find_package(OpenCV 3 REQUIRED)
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <string> #include <string>
#include <ctime> #include <ctime>
#include <cstdio> #include <cstdio>
#include <filesystem>
#include <opencv2/core.hpp> #include <opencv2/core.hpp>
#include <opencv2/core/utility.hpp> #include <opencv2/core/utility.hpp>
...@@ -567,7 +568,11 @@ static void saveCameraParams( Settings& s, Size& imageSize, Mat& cameraMatrix, M ...@@ -567,7 +568,11 @@ static void saveCameraParams( Settings& s, Size& imageSize, Mat& cameraMatrix, M
const vector<float>& reprojErrs, const vector<vector<Point2f> >& imagePoints, const vector<float>& reprojErrs, const vector<vector<Point2f> >& imagePoints,
double totalAvgErr ) double totalAvgErr )
{ {
filesystem::create_directories(filesystem::path(s.outputFileName).parent_path());
FileStorage fs( s.outputFileName, FileStorage::WRITE ); FileStorage fs( s.outputFileName, FileStorage::WRITE );
if (!fs.isOpened())
throw std::runtime_error("Could not open camara parameters file for writing");
time_t tm; time_t tm;
time( &tm ); time( &tm );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment