JeVois  1.22
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
Coordinates.C
Go to the documentation of this file.
1// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2//
3// JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2016 by Laurent Itti, the University of Southern
4// California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5//
6// This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7// redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8// Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10// License for more details. You should have received a copy of the GNU General Public License along with this program;
11// if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12//
13// Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14// Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16/*! \file */
17
19#include <cmath>
20
21// ####################################################################################################
22void jevois::coords::imgToStd(float & x, float & y, jevois::RawImage const & camimg, float const eps)
23{ jevois::coords::imgToStd(x, y, camimg.width, camimg.height, eps); }
24
25// ####################################################################################################
26void jevois::coords::imgToStd(float & x, float & y, unsigned int const width, unsigned int const height,
27 float const eps)
28{
29 x = 2000.0F * x / width - 1000.0F;
30 y = (1.0F / JEVOIS_CAMERA_ASPECT) * (2000.0F * y / height - 1000.0F);
31
32 if (eps) { x = std::round(x / eps) * eps; y = std::round(y / eps) * eps; }
33}
34
35// ####################################################################################################
36void jevois::coords::imgToStdX(float & x, unsigned int const width, float const eps)
37{
38 x = 2000.0F * x / width - 1000.0F;
39 if (eps) x = std::round(x / eps) * eps;
40}
41
42// ####################################################################################################
43void jevois::coords::imgToStdY(float & y, unsigned int const height, float const eps)
44{
45 y = (1.0F / JEVOIS_CAMERA_ASPECT) * (2000.0F * y / height - 1000.0F);
46 if (eps) y = std::round(y / eps) * eps;
47}
48
49// ####################################################################################################
50void jevois::coords::imgToStdSize(float & w, float & h, unsigned int const width, unsigned int const height,
51 float const eps)
52{
53 w = 2000.0F * w / width;
54 h = (1.0F / JEVOIS_CAMERA_ASPECT) * (2000.0F * h / height);
55
56 if (eps) { w = std::round(w / eps) * eps; h = std::round(h / eps) * eps; }
57}
58
59// ####################################################################################################
60void jevois::coords::stdToImg(float & x, float & y, jevois::RawImage const & camimg, float const eps)
61{ jevois::coords::stdToImg(x, y, camimg.width, camimg.height, eps); }
62
63// ####################################################################################################
64void jevois::coords::stdToImg(float & x, float & y, unsigned int const width, unsigned int const height,
65 float const eps)
66{
67 x = (x * 0.0005F + 0.5F) * width;
68 y = (JEVOIS_CAMERA_ASPECT * y * 0.0005F + 0.5F) * height;
69
70 if (eps) { x = std::round(x / eps) * eps; y = std::round(y / eps) * eps; }
71}
72
73// ####################################################################################################
74void jevois::coords::stdToImgSize(float & w, float & h, unsigned int const width, unsigned int const height,
75 float const eps)
76{
77 w = (w * 0.0005F) * width;
78 h = (JEVOIS_CAMERA_ASPECT * h * 0.0005F) * height;
79
80 if (eps) { w = std::round(w / eps) * eps; h = std::round(h / eps) * eps; }
81}
int h
Definition GUIhelper.C:2520
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Definition RawImage.H:111
unsigned int width
Image width in pixels.
Definition RawImage.H:145
unsigned int height
Image height in pixels.
Definition RawImage.H:146
#define JEVOIS_CAMERA_ASPECT
Aspect ratio of the JeVois camera.
Definition Coordinates.H:67
void imgToStdX(float &x, unsigned int const width, float const eps=0.1F)
Transform X coordinate in-place from camera to standardized, using given image width and height.
Definition Coordinates.C:36
void stdToImg(float &x, float &y, RawImage const &camimg, float const eps=0.1F)
Transform coordinates in-place from standardized to image, using a RawImage to establish image size.
Definition Coordinates.C:60
void imgToStdY(float &y, unsigned int const height, float const eps=0.1F)
Transform Y coordinate in-place from camera to standardized, using given image width and height.
Definition Coordinates.C:43
void imgToStd(float &x, float &y, RawImage const &camimg, float const eps=0.1F)
Transform coordinates in-place from camera to standardized, using a RawImage to establish image size.
Definition Coordinates.C:22
void imgToStdSize(float &w, float &h, unsigned int const width, unsigned int const height, float const eps=0.1F)
Transform size in-place from camera to standardized, using given image width and height.
Definition Coordinates.C:50
void stdToImgSize(float &x, float &y, unsigned int const width, unsigned int const height, float const eps=0.1F)
Transform size in-place from standardized to image, using a RawImage to establish image size.
Definition Coordinates.C:74