00001
00002
00003
00004
00005 #if !defined (AQSENSE_SAL3DPP_ANGULAR_METRIC_CONFIG_HPP)
00006 #define AQSENSE_SAL3DPP_ANGULAR_METRIC_CONFIG_HPP
00007
00008 #if defined (_MSC_VER) && (_MSC_VER >= 1020)
00009 #pragma once
00010 #endif
00011
00012 #include <limits>
00013 #include <string>
00014 #include <cassert>
00015 #include <cstddef>
00016 #include <stdexcept>
00017 #include <vector>
00018 #include <sal3dpp/Common.hpp>
00019 #include <sal3dpp/RangeMap.hpp>
00020 #include <sal3d/angularmetricconfig.h>
00021
00022 namespace sal3d
00023 {
00065 namespace AngularMetric
00066 {
00090 class Config
00091 {
00092 public:
00107 explicit Config (
00108 const sal3d_angular_metric_config &config):
00109 _config (config)
00110 {
00111 Error e;
00112 sal3d_angular_metric_config_check_validity (config, &e.e);
00113 if (e.e.value < 0)
00114 throw e;
00115 }
00116
00124 Config (const Config &mc)
00125 : _config(mc._config)
00126 {
00127 Error e;
00128 sal3d_angular_metric_config_share(_config, &e.e);
00129 if (e.e.value < 0)
00130 throw e;
00131 }
00132
00142 Config &
00143 operator= (const Config &mc)
00144 {
00145 _config = mc._config;
00146 Error e;
00147 sal3d_angular_metric_config_share(_config, &e.e);
00148 if (e.e.value < 0)
00149 throw e;
00150 return *this;
00151 }
00152
00161 explicit Config (const std::string &filename)
00162 {
00163 _config.p = 0;
00164 Error e;
00165 sal3d_angular_metric_config_new_from_file (
00166 filename.c_str (), &_config, &e.e);
00167 if (e.e.value < 0)
00168 throw e;
00169 }
00170
00174 ~Config ()
00175 {
00176 sal3d_angular_metric_config_release (_config);
00177 }
00178
00198 std::vector<float> accuracyMean() const
00199 {
00200 std::vector<float> vec(3);
00201 Error e;
00202 sal3d_angular_metric_config_get_accuracy_mean(_config,
00203 &vec[0], &vec[1], &vec[2], &e.e);
00204 if (e.e.value < 0)
00205 throw e;
00206 return vec;
00207 }
00208
00229 std::vector<float> accuracyStdDev() const
00230 {
00231 std::vector<float> vec(3);
00232 Error e;
00233 sal3d_angular_metric_config_get_accuracy_stddev(_config,
00234 &vec[0], &vec[1], &vec[2], &e.e);
00235 if (e.e.value < 0)
00236 throw e;
00237 return vec;
00238 }
00239
00251 const sal3d_angular_metric_config &
00252 c_metric_config () const
00253 {
00254 return _config;
00255 }
00256
00265 void
00266 saveToFile (const std::string &fileName) const
00267 {
00268 Error e;
00269 sal3d_angular_metric_config_save_to_file (_config,
00270 fileName.c_str (), &e.e);
00271 if (e.e.value < 0)
00272 throw e;
00273 }
00274
00292 Point3D
00293 toPoint3D (float angle, int v, float g) const
00294 {
00295 Point3D point3d;
00296 Error e;
00297 sal3d_angular_metric_config_point3d_from_range_map_point (v, g,
00298 angle, _config, &point3d.c_point_3d(), &e.e);
00299 if (e.e.value < 0)
00300 throw e;
00301 return point3d;
00302 }
00303
00316 LensDistortion::Model
00317 getLensDistortionModel() const
00318 {
00319 sal3d_lens_distortion dm;
00320 Error e;
00321 sal3d_angular_metric_config_get_lens_distortion(
00322 _config, &dm, &e.e);
00323 if (e.e.value < 0)
00324 throw e;
00325
00326 return LensDistortion::Model(dm);
00327 }
00328
00329 private:
00331 sal3d_angular_metric_config _config;
00332 };
00333 }
00334 }
00335
00336 #endif // !AQSENSE_SAL3DPP_ANGULAR_METRIC_CONFIG_HPP