// -*- mode: c++ -*-
-#ifndef __FACE_DETECTOR_MATH_UTILS_H__
-#define __FACE_DETECTOR_MATH_UTILS_H__
+#ifndef FACE_DETECTOR_MATH_UTILS_H
+#define FACE_DETECTOR_MATH_UTILS_H
/****
-Copyright (c) 2020 Adrian I. Lam
+Copyright (c) 2020-2021 Adrian I. Lam
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
#include <cmath>
#include <initializer_list>
-#include <dlib/image_processing.h>
static const double PI = 3.14159265358979;
return sum / container.size();
}
+
template<class... Args>
-static dlib::point centroid(Args&... args)
+static Point centroid(Args&... args)
{
std::size_t numArgs = sizeof...(args);
- if (numArgs == 0) return dlib::point(0, 0);
+ if (numArgs == 0) return Point(0, 0);
double sumX = 0, sumY = 0;
for (auto point : {args...})
{
- sumX += point.x();
- sumY += point.y();
+ sumX += point.x;
+ sumY += point.y;
}
- return dlib::point(sumX / numArgs, sumY / numArgs);
+ return Point(sumX / numArgs, sumY / numArgs);
}
static inline double sq(double x)
return deg * PI / 180;
}
-double dist(dlib::point& p1, dlib::point& p2)
+double dist(Point& p1, Point& p2)
{
- double xDist = p1.x() - p2.x();
- double yDist = p1.y() - p2.y();
+ double xDist = p1.x - p2.x;
+ double yDist = p1.y - p2.y;
return std::hypot(xDist, yDist);
}