57 #ifndef _RNR_WIN_OPEN_CV_H 58 #define _RNR_WIN_OPEN_CV_H 63 #include "rnr/rnrconfig.h" 65 #include "opencv2/core/core.hpp" 77 #define CHANNEL_GRAY -1 80 #define CHANNEL_BLUE 0 81 #define CHANNEL_GREEN 1
86 #define CHANNEL_SATURATION 1
87 #define CHANNEL_VALUE 2
89 const cv::Point
nopoint(-1, -1);
91 const cv::Point3f
nopoint3D(-1.0, -1.0, -1.0);
102 return (pt.x < 0) || (pt.y < 0)?
true:
false;
114 return (pt.x < 0.0) || (pt.y < 0.0)?
true:
false;
126 return (pt.x < 0.0) || (pt.y < 0.0) || (pt.z < 0.0)?
true:
false;
137 inline int distL1(
const cv::Point &p1,
const cv::Point &p2)
139 return (
int)(fabs((
double)(p1.x-p2.x)) + fabs((
double)(p1.y-p2.y)));
150 inline int distL1(
const cv::Point2f &p1,
const cv::Point2f &p2)
152 return fabs(p1.x-p2.x) + fabs(p1.y-p2.y);
163 inline int distL1(
const cv::Point3f &p1,
const cv::Point3f &p2)
165 return fabs(p1.x-p2.x) + fabs(p1.y-p2.y) + fabs(p1.z-p2.z);
176 inline int distL2(
const cv::Point &p1,
const cv::Point &p2)
178 return (
int)sqrt( (
double)((p1.x-p2.x)*(p1.x-p2.x)) +
179 (
double)((p1.y-p2.y)*(p1.y-p2.y)) );
190 inline double distL2(
const cv::Point2f &p1,
const cv::Point2f &p2)
192 return sqrt( (p1.x-p2.x)*(p1.x-p2.x) + (p1.y-p2.y)*(p1.y-p2.y) );
203 inline double distL2(
const cv::Point3f &p1,
const cv::Point3f &p2)
205 return sqrt( (p1.x-p2.x)*(p1.x-p2.x) +
206 (p1.y-p2.y)*(p1.y-p2.y) +
207 (p1.z-p2.z)*(p1.z-p2.z) );
218 inline int distLinf(
const cv::Point &p1,
const cv::Point &p2)
220 return (
int)fmax(fabs((
double)(p1.x-p2.x)), fabs((
double)(p1.y-p2.y)));
231 inline int distLinf(
const cv::Point2f &p1,
const cv::Point2f &p2)
233 return fmax(fabs(p1.x-p2.x), fabs(p1.y-p2.y));
244 inline int distLinf(
const cv::Point3f &p1,
const cv::Point3f &p2)
246 return fmax(fmax(fabs(p1.x-p2.x), fabs(p1.y-p2.y)), fabs(p1.z-p2.z));
260 return (x >= r.x) && (x < r.x+r.width) && (y >= r.y) && (y < r.y+r.height)?
277 siz43.height = (3 * (w-r)) / 4;
278 siz43.width = (4 * siz43.height) / 3;
294 siz43.height = (3 * (w-r)) / 4;
295 siz43.width = (4 * siz43.height) / 3;
312 siz43.width = (4 * (h-r)) / 3;
313 siz43.height = (3 * siz43.width) / 4;
329 siz43.width = (4 * (h-r)) / 3;
330 siz43.height = (3 * siz43.width) / 4;
340 inline void dbgrect(
const std::string &str,
const cv::Rect &r)
342 fprintf(stderr,
"%s=(%d,%d,%d,%d)\n",
343 str.c_str(), r.x, r.y, r.width, r.height);
352 inline void dbgpoint(
const std::string &str,
const cv::Point &pt)
354 fprintf(stderr,
"%s=(%d,%d)\n", str.c_str(), pt.x, pt.y);
363 inline void dbgsize(
const std::string &str,
const cv::Size &siz)
365 fprintf(stderr,
"%s=(%d,%d)\n", str.c_str(), siz.width, siz.height);
370 #endif // _RNR_WIN_OPEN_CV_H cv::Size ar43height(cv::Size &siz)
Calculate the nearest 4:3 aspect ratio from the height component of the target size.
int distLinf(const cv::Point &p1, const cv::Point &p2)
Calculate the Linf distance between two 2D points.
void dbgrect(const std::string &str, const cv::Rect &r)
Debug print rectangle.
const cv::Point3f nopoint3D(-1.0,-1.0,-1.0)
fpn 3D "No Point"
int distL2(const cv::Point &p1, const cv::Point &p2)
Calculate the L2 (euclidean) distance between two 2D points.
void dbgsize(const std::string &str, const cv::Size &siz)
Debug print size.
const cv::Point nopoint(-1,-1)
integer 2D "No Point"
cv::Size ar43width(cv::Size &siz)
Calculate the nearest 4:3 aspect ratio from the width component of the target size.
void dbgpoint(const std::string &str, const cv::Point &pt)
Debug print point.
const cv::Point2f nopoint2D(-1.0,-1.0)
fpn 2D "No Point"
int distL1(const cv::Point &p1, const cv::Point &p2)
Calculate the L1 (taxi cab) distance between two 2D points.
bool isnopoint(const cv::Point &pt)
Check if point is not set ("no point").
bool isinrect(int x, int y, cv::Rect &r)
Check if point x,y is with rectangle r.