Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
ArucoSamplesUtility.hpp
1/*
2By downloading, copying, installing or using the software you agree to this
3license. If you do not agree to this license, do not download, install,
4copy or use the software.
5
6 License Agreement
7 For Open Source Computer Vision Library
8 (3-clause BSD License)
9
10Copyright (C) 2013, OpenCV Foundation, all rights reserved.
11Third party copyrights are property of their respective owners.
12
13Redistribution and use in source and binary forms, with or without modification,
14are permitted provided that the following conditions are met:
15
16 * Redistributions of source code must retain the above copyright notice,
17 this list of conditions and the following disclaimer.
18
19 * Redistributions in binary form must reproduce the above copyright notice,
20 this list of conditions and the following disclaimer in the documentation
21 and/or other materials provided with the distribution.
22
23 * Neither the names of the copyright holders nor the names of the contributors
24 may be used to endorse or promote products derived from this software
25 without specific prior written permission.
26
27This software is provided by the copyright holders and contributors "as is" and
28any express or implied warranties, including, but not limited to, the implied
29warranties of merchantability and fitness for a particular purpose are
30disclaimed. In no event shall copyright holders or contributors be liable for
31any direct, indirect, incidental, special, exemplary, or consequential damages
32(including, but not limited to, procurement of substitute goods or services;
33loss of use, data, or profits; or business interruption) however caused
34and on any theory of liability, whether in contract, strict liability,
35or tort (including negligence or otherwise) arising in any way out of
36the use of this software, even if advised of the possibility of such damage.
37*/
38
40#include <ctime>
41#include <opencv2/calib3d.hpp>
42#include <opencv2/highgui.hpp>
44
46
47namespace
48{
49 inline static bool readCameraParameters(std::string filename, cv::Mat& camMatrix, cv::Mat& distCoeffs)
50 {
52 if (!fs.isOpened())
53 return false;
54 fs["camera_matrix"] >> camMatrix;
55 fs["distortion_coefficients"] >> distCoeffs;
56 return true;
57 }
58
59 inline static bool saveCameraParams(const std::string& filename,
60 cv::Size imageSize,
61 float aspectRatio,
62 int flags,
63 const cv::Mat& cameraMatrix,
64 const cv::Mat& distCoeffs,
65 double totalAvgErr)
66 {
68 if (!fs.isOpened())
69 return false;
70
71 time_t tt;
72 time(&tt);
73 struct tm* t2 = localtime(&tt);
74 char buf[1024];
75 strftime(buf, sizeof(buf) - 1, "%c", t2);
76
77 fs << "calibration_time" << buf;
78 fs << "image_width" << imageSize.width;
79 fs << "image_height" << imageSize.height;
80
82 fs << "aspectRatio" << aspectRatio;
83
84 if (flags != 0)
85 {
86 sprintf(buf,
87 "flags: %s%s%s%s",
88 flags & cv::CALIB_USE_INTRINSIC_GUESS ? "+use_intrinsic_guess" : "",
89 flags & cv::CALIB_FIX_ASPECT_RATIO ? "+fix_aspectRatio" : "",
90 flags & cv::CALIB_FIX_PRINCIPAL_POINT ? "+fix_principal_point" : "",
91 flags & cv::CALIB_ZERO_TANGENT_DIST ? "+zero_tangent_dist" : "");
92 }
93 fs << "flags" << flags;
94 fs << "camera_matrix" << cameraMatrix;
95 fs << "distortion_coefficients" << distCoeffs;
96 fs << "avg_reprojection_error" << totalAvgErr;
97 return true;
98 }
99
100} // namespace
CALIB_FIX_ASPECT_RATIO
CALIB_FIX_PRINCIPAL_POINT
CALIB_USE_INTRINSIC_GUESS
CALIB_ZERO_TANGENT_DIST