50 #include <visp3/core/vpException.h> 51 #include <visp3/core/vpMath.h> 52 #include <visp3/core/vpMatrix.h> 54 #if defined(VISP_HAVE_FUNC__ISNAN) 58 #if !(defined(VISP_HAVE_FUNC_ISNAN) || defined(VISP_HAVE_FUNC_STD_ISNAN)) || \ 59 !(defined(VISP_HAVE_FUNC_ISINF) || defined(VISP_HAVE_FUNC_STD_ISINF)) 60 #if defined _MSC_VER || defined __BORLANDC__ 61 typedef __int64 int64;
62 typedef unsigned __int64 uint64;
64 typedef int64_t int64;
65 typedef uint64_t uint64;
68 #ifndef DOXYGEN_SHOULD_SKIP_THIS 69 typedef union Cv64suf {
77 const double vpMath::ang_min_sinc = 1.0e-8;
78 const double vpMath::ang_min_mc = 2.5e-4;
87 #if defined(VISP_HAVE_FUNC_ISNAN) 89 #elif defined(VISP_HAVE_FUNC_STD_ISNAN) 90 return std::isnan(value);
91 #elif defined(VISP_HAVE_FUNC__ISNAN) 92 return (_isnan(value) != 0);
97 return (value != value);
102 return (((
unsigned)(ieee754.u >> 32) & 0x7fffffff) + ((
unsigned)ieee754.u != 0) > 0x7ff00000) != 0;
113 #if defined(VISP_HAVE_FUNC_ISINF) 115 #elif defined(VISP_HAVE_FUNC_STD_ISINF) 116 return std::isinf(value);
117 #elif defined(VISP_HAVE_FUNC__FINITE) 118 return !_finite(value);
123 return ((
unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 && (unsigned)ieee754.u == 0;
138 if (fabs(x) < ang_min_mc)
141 return ((1.0 - cosx) / x / x);
155 if (fabs(x) < ang_min_mc)
158 return ((1.0 - sinx / x) / x / x);
171 if (fabs(x) < ang_min_sinc)
187 if (fabs(x) < ang_min_sinc)
206 size_t size = v.size();
208 double sum = std::accumulate(v.begin(), v.end(), 0.0);
210 return sum / (double)size;
226 std::vector<double> v_copy = v;
227 size_t size = v_copy.size();
230 std::nth_element(v_copy.begin(), v_copy.begin() + n, v_copy.end());
231 double val_n = v_copy[n];
236 std::nth_element(v_copy.begin(), v_copy.begin() + n - 1, v_copy.end());
237 return 0.5 * (val_n + v_copy[n - 1]);
256 double mean = getMean(v);
258 std::vector<double> diff(v.size());
259 #if VISP_CXX_STANDARD > VISP_CXX_STANDARD_98 260 std::transform(v.begin(), v.end(), diff.begin(), std::bind(std::minus<double>(), std::placeholders::_1, mean));
262 std::transform(v.begin(), v.end(), diff.begin(), std::bind2nd(std::minus<double>(), mean));
265 double sq_sum = std::inner_product(diff.begin(), diff.end(), diff.begin(), 0.0);
266 double divisor = (double)v.size();
267 if (useBesselCorrection && v.size() > 1) {
268 divisor = divisor - 1;
271 return std::sqrt(sq_sum / divisor);
289 if (imPts.size() < 3) {
293 double x_mean = 0, y_mean = 0;
294 for (
size_t i = 0; i < imPts.size(); i++) {
296 x_mean += imPt.
get_u();
297 y_mean += imPt.
get_v();
299 x_mean /= imPts.size();
300 y_mean /= imPts.size();
303 for (
size_t i = 0; i < imPts.size(); i++) {
305 AtA[0][0] += (imPt.
get_u() - x_mean)*(imPt.
get_u() - x_mean);
306 AtA[0][1] += (imPt.
get_u() - x_mean)*(imPt.
get_v() - y_mean);
307 AtA[1][1] += (imPt.
get_v() - y_mean)*(imPt.
get_v() - y_mean);
309 AtA[1][0] = AtA[0][1];
315 a = eigenvectors[0][0];
316 b = eigenvectors[1][0];
317 c = a*x_mean + b*y_mean;
320 for (
size_t i = 0; i < imPts.size(); i++) {
321 double x0 = imPts[i].get_u();
322 double y0 = imPts[i].get_v();
324 error += std::fabs(a*x0 + b*y0 - c);
327 return error / imPts.size();
Implementation of a matrix and operations on matrices.
vpColVector eigenValues() const
static double lineFitting(const std::vector< vpImagePoint > &imPts, double &a, double &b, double &c)
static double getMedian(const std::vector< double > &v)
static double getStdev(const std::vector< double > &v, bool useBesselCorrection=false)
error that can be emited by ViSP classes.
static double sinc(double x)
static double getMean(const std::vector< double > &v)
static double mcosc(double cosx, double x)
static bool isNaN(double value)
Implementation of column vector and the associated operations.
Used to indicate that a parameter is not initialized.
static bool isInf(double value)
static int modulo(int a, int n)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
static double msinc(double sinx, double x)