4 #ifndef GEOMETRY_HEADER
5 #define GEOMETRY_HEADER
7 #define ONEOVERSQRT2PI 0.39894228f
9 #include "GlobalHeader.h"
17 Size(
int w = 0,
int h = 0);
23 Size operator*(
float f);
24 bool operator==(
const Size &other)
const;
26 inline explicit operator cv::Size()
const {
27 return cv::Size(width, height);
31 bool IsIn(
int upper,
int left,
int width,
int height)
const;
36 Rect(
int u = 0,
int l = 0,
int w = 0,
int h = 0)
37 : upper(u), left(l), width(w), height(h) {}
47 bool IsOverlap(
const Rect &other)
const;
53 if (other.upper > upper && other.left > left &&
54 other.upper + other.height < upper + height &&
55 other.left + other.width < left + width) {
64 explicit operator cv::Rect()
const;
66 explicit operator Size()
const;
75 inline float SquaredDistance(
const Point2D &other)
const {
76 return (
float)((row - other.row) * (row - other.row) + (col - other.col) * (col - other.col));
79 inline float Distance(
const Point2D &other)
const {
80 return sqrtf(SquaredDistance(other));
83 inline float SquaredLength()
const {
84 return (
float)(row * row + col * col);
87 inline float Length()
const {
88 return sqrtf(SquaredLength());
92 return Point2D(row - other.row, col - other.col);
95 inline float operator*(
const Point2D &other)
const {
96 return (
float)(row * other.row + col * other.col);
99 inline Point2D operator*(
float scale)
const {
100 return Point2D(row * scale, col * scale);
108 float dot = (*this) * other;
109 return (other - (*
this)*(dot / SquaredLength())).Length();
115 inline float GetGaussianProb(
float mean,
float sigma,
float value) {
116 float invSimga = 1.0f / sigma;
117 return ONEOVERSQRT2PI * invSimga * expf(-0.5f * powf((value - mean) * invSimga, 2.0f));
Definition: Geometry.h:34
bool IsIn(const Rect &other) const
Definition: Geometry.h:52
Definition: Geometry.h:14
float ProjectResidual(const Point2D &other) const
Definition: Geometry.h:107
Definition: ImageDetector.h:16
Definition: Geometry.h:69