00001
00002
00003
00004
00005 #if !defined (AQSENSE_SAL3DPP_METRIC_HPP)
00006 #define AQSENSE_SAL3DPP_METRIC_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 <sal3d/metric.h>
00019 #include <sal3dpp/Common.hpp>
00020 #include <sal3dpp/RangeMap.hpp>
00021
00022 namespace sal3d
00023 {
00075 namespace Metric
00076 {
00085 typedef sal3d_pattern_lp_points PatternLPPoints;
00086
00129 inline Config
00130 calibrate (const RangeMap &rangeMap, const PatternLPPoints &points,
00131 int left, int top, int right, int bottom,
00132 const LensDistortion::Model &dm, float gFactor = 1.f)
00133 {
00134 sal3d_metric_config metricConfig;
00135 Error e;
00136 sal3d_metric_calibrate_range_map_cropped (
00137 rangeMap.c_range_map(), points, left, top, right, bottom,
00138 &dm.c_lens_distortion(), gFactor, &metricConfig, &e.e);
00139 if (e.e.value < 0)
00140 throw e;
00141
00142 return Config(metricConfig);
00143 }
00144
00181 inline Config
00182 calibrate (const RangeMap &rangeMap, const PatternLPPoints &points,
00183 int left, int top, int right, int bottom)
00184 {
00185 const LensDistortion::Model dm;
00186 return calibrate(rangeMap, points, left, top, right, bottom, dm);
00187 }
00188
00213 inline Config
00214 calibrate (const RangeMap &rangeMap, const PatternLPPoints &points)
00215 {
00216 return calibrate(rangeMap, points, 0, 0,
00217 rangeMap.profilesLength()-1, rangeMap.countProfiles()-1);
00218 }
00219
00270 inline Config
00271 calibrate (const Profile &profile, const PatternSPPoints &points,
00272 int left, int right, const LensDistortion::Model &model =
00273 LensDistortion::Model(), float xStep = 0, float gFactor = 1.f)
00274 {
00275 sal3d_metric_config metricConfig;
00276 Error e;
00277 sal3d_metric_calibrate_profile (profile.c_profile(), points,
00278 xStep, left, right, &model.c_lens_distortion(), gFactor,
00279 &metricConfig, &e.e);
00280 if (e.e.value < 0)
00281 throw e;
00282
00283 return Config(metricConfig);
00284 }
00285
00316 inline Config
00317 calibrate (const Profile &profile, const PatternSPPoints &points,
00318 const LensDistortion::Model &model = LensDistortion::Model(),
00319 float xStep = 0, float gFactor = 1.f)
00320 {
00321 return calibrate(profile, points, 0, profile.length()-1,
00322 model, xStep, gFactor);
00323 }
00324
00369 inline Config
00370 calibrate (const Profile &profile, const PatternSPPoints &points,
00371 int left, int right, float xStep = 0)
00372 {
00373 const LensDistortion::Model dm;
00374 return calibrate(profile, points, left, right, dm, xStep);
00375 }
00376
00414 inline Config
00415 calibrate (const Profile &profile, const PatternSPPoints &points,
00416 float xStep = 0)
00417 {
00418 return calibrate(profile, points, 0, profile.length()-1, xStep);
00419 }
00420
00471 inline Config
00472 calibrate (const Profile &profile, const PatternSTPPoints &points,
00473 int left, int right, const LensDistortion::Model &model =
00474 LensDistortion::Model(), float xStep = 0, float gFactor = 1.f)
00475 {
00476 sal3d_metric_config metricConfig;
00477 Error e;
00478 sal3d_metric_calibrate_step_profile (profile.c_profile(), points,
00479 xStep, left, right, &model.c_lens_distortion(), gFactor,
00480 &metricConfig, &e.e);
00481 if (e.e.value < 0)
00482 throw e;
00483
00484 return Config(metricConfig);
00485 }
00486
00514 inline Config
00515 calibrate (const Profile &profile, const PatternSTPPoints &points,
00516 const LensDistortion::Model &model = LensDistortion::Model(),
00517 float xStep = 0, float gFactor = 1.f)
00518 {
00519 return calibrate(profile, points, 0, profile.length()-1,
00520 model, xStep, gFactor);
00521 }
00522
00549 inline Config
00550 calibrate (const Profile &profile, const PatternSTPPoints &points,
00551 int left, int right, float xStep = 0)
00552 {
00553 const LensDistortion::Model dm;
00554 return calibrate(profile, points, left, right, dm, xStep);
00555 }
00556
00582 inline Config
00583 calibrate (const Profile &profile, const PatternSTPPoints &points,
00584 float xStep = 0)
00585 {
00586 return calibrate(profile, points, 0, profile.length()-1, xStep);
00587 }
00588 }
00589 }
00590
00591 #endif // !AQSENSE_SAL3DPP_METRIC_HPP