JeVois  1.0
JeVois Smart Embedded Machine Vision Toolkit
Helper functions to convert coordinates from camera resolution to standardized

Different machine vision algorithms in JeVois may be able to operate with different camera resolutions, such as 1280x1024, 320x240, or 176x144. When some item of interest is detected in the camera frame, one may often want to send the coordinates of that thing to the serial port. This poses a problem if one were to directly send the image coordinates of the item out, which is that now the receiver (e.g., an Arduino) needs to know which camera image resolution was used, so that it can properly interpret these coordinates. For example, if the visual attention (saliency) algorithm is running with 640x480 camera input, then a salient object at the center of the camera's field of view would have coordinates 320,240. But if the same saliency algorithm is configures to process 320x240 input ideo (so that it can run at a higher framerate), now an object at the center of the field of view would have coordinates 160,120. If one connects an Arduino that controls, for example, a pan/tilt head to JeVois, we need a way to communicate coordinates of target objects in the world independently of the video resolution used by the camera.

Thus, JeVois defines a standardized coordinate system, as follows:

Note that the value of 750 here comes from the assumption of a 4:3 aspect ratio for the camera sensor, and is actually defined in JEVOIS_CAMERA_ASPECT.

When writing a machine vision algorithm that sends over serial the coordinates of things detected in the camera frames, be sure to first transform those coordinates from image to standardized space.

Collaboration diagram for Helper functions to convert coordinates from camera resolution to standardized:

Macros

#define JEVOIS_CAMERA_ASPECT   (4.0 / 3.0)
 Aspect ratio of the JeVois camera. More...
 

Functions

void jevois::coords::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. More...
 
void jevois::coords::imgToStd (float &x, float &y, unsigned int const width, unsigned int const height, float const eps=0.1F)
 Transform coordinates in-place from camera to standardized, using given image width and height. More...
 
void jevois::coords::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. More...
 
void jevois::coords::stdToImg (float &x, float &y, unsigned int const width, unsigned int const height, float const eps=0.1F)
 Transform coordinates in-place from standardized to image, using a RawImage to establish image size. More...
 

Macro Definition Documentation

#define JEVOIS_CAMERA_ASPECT   (4.0 / 3.0)

Aspect ratio of the JeVois camera.

Definition at line 58 of file Coordinates.H.

Referenced by jevois::coords::imgToStd(), and jevois::coords::stdToImg().

Function Documentation

void jevois::coords::imgToStd ( float &  x,
float &  y,
jevois::RawImage const &  camimg,
float const  eps = 0.1F 
)

Transform coordinates in-place from camera to standardized, using a RawImage to establish image size.

The RawImage from the camera is used to specify pixel width and height of the camera image, and this is the source coordinate system. The destination coordinate system is the standardized one, with x in [-1000 ... 1000] and y in [-750 ... 750].

eps is used for rounding of returned coordinates, which is convenient to avoid sending very long floating point values over serial port.

Definition at line 22 of file Coordinates.C.

References jevois::RawImage::height, and jevois::RawImage::width.

void jevois::coords::imgToStd ( float &  x,
float &  y,
unsigned int const  width,
unsigned int const  height,
float const  eps = 0.1F 
)

Transform coordinates in-place from camera to standardized, using given image width and height.

The width and height are used to specify pixel width and height of the camera image, and this is the source coordinate system. The destination coordinate system is the standardized one, with x in [-1000 ... 1000] and y in [-750 ... 750].

eps is used for rounding of returned coordinates, which is convenient to avoid sending very long floating point values over serial port.

Definition at line 26 of file Coordinates.C.

References JEVOIS_CAMERA_ASPECT.

void jevois::coords::stdToImg ( float &  x,
float &  y,
jevois::RawImage const &  camimg,
float const  eps = 0.1F 
)

Transform coordinates in-place from standardized to image, using a RawImage to establish image size.

The RawImage would typically be from the camera is used to specify pixel width and height of the camera image, and this is the destination coordinate system. The source coordinate system is the standardized one, with x in [-1000 ... 1000] and y in [-750 ... 750].

eps is used for rounding of returned coordinates, which is convenient to avoid sending very long floating point values over serial port.

Definition at line 36 of file Coordinates.C.

References jevois::RawImage::height, and jevois::RawImage::width.

void jevois::coords::stdToImg ( float &  x,
float &  y,
unsigned int const  width,
unsigned int const  height,
float const  eps = 0.1F 
)

Transform coordinates in-place from standardized to image, using a RawImage to establish image size.

The witdth and height would typically be from the camera and are used to specify pixel width and height of the camera image, and this is the destination coordinate system. The source coordinate system is the standardized one, with x in [-1000 ... 1000] and y in [-750 ... 750].

eps is used for rounding of returned coordinates, which is convenient to avoid sending very long floating point values over serial port.

Definition at line 40 of file Coordinates.C.

References JEVOIS_CAMERA_ASPECT.