JeVois  1.2
JeVois Smart Embedded Machine Vision Toolkit
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 // ####################################################################################################
22 void 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 // ####################################################################################################
26 void 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 // ####################################################################################################
36 void jevois::coords::stdToImg(float & x, float & y, jevois::RawImage const & camimg, float const eps)
37 { jevois::coords::stdToImg(x, y, camimg.width, camimg.height, eps); }
38 
39 // ####################################################################################################
40 void jevois::coords::stdToImg(float & x, float & y, unsigned int const width, unsigned int const height,
41  float const eps)
42 {
43  x = (x * 0.0005F + 0.5F) * width;
44  y = (JEVOIS_CAMERA_ASPECT * y * 0.0005F + 0.5F) * height;
45 
46  if (eps) { x = std::round(x / eps) * eps; y = std::round(y / eps) * eps; }
47 }
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
unsigned int height
Image height in pixels.
Definition: RawImage.H:146
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:36
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Definition: RawImage.H:110
#define JEVOIS_CAMERA_ASPECT
Aspect ratio of the JeVois camera.
Definition: Coordinates.H:58
unsigned int width
Image width in pixels.
Definition: RawImage.H:145