Defines | Functions | Variables

barcam.cxx File Reference

#include <inttypes.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <semaphore.h>
#include <getopt.h>
#include <unistd.h>
#include <fftw3.h>
#include <string>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include "c2gnuplot.h"
#include <roboorte_robottype.h>
Include dependency graph for barcam.cxx:

Defines

#define BARCAM_DEBUG
#define WITH_GUI
#define MODE_QUIT   0x01
#define MODE_VIDEO   0x02
#define MODE_RECOGNIZE   0x04
#define MODE_WAIT   0x08
#define MODE_IMAGE   0x10
#define WINDOW_ORIG   "BARCAM original scene"
#define WINDOW_PROD   "BARCAM recognition product"
#define WINDOW_WIDTH   640
#define WINDOW_HEIGHT   480
#define ROI_X   0
#define ROI_Y   0
#define ROI_WIDTH   WINDOW_WIDTH
#define ROI_HEIGHT   WINDOW_HEIGHT
#define KEY_ESC   0x1B
#define KEY_SPACE   0x20
#define KEY_O   0x4f
#define KEY_P   0x50
#define KEY_R   0x52
#define KEY_S   0x53
#define KEY_V   0x56
#define KEY_W   0x57
#define KEY_o   0x6f
#define KEY_p   0x70
#define KEY_r   0x72
#define KEY_s   0x73
#define KEY_v   0x76
#define KEY_w   0x77
#define KEY_PLUS   0x2B
#define KEY_MINUS   0x2D
#define KEY_1   0x31
#define KEY_2   0x32
#define KEY_3   0x33
#define KEY_4   0x34
#define KEY_5   0x35
#define KEY_6   0x36
#define KEY_7   0x37
#define KEY_8   0x38
#define SNAPSHOTFILENAME   "snapshot%02d.png"

Functions

int saveFrame (const CvArr *img)
 Saves current image to a new file in the current directory.
void selectROI (CvCapture *capture, CvRect *roi)
 Setting region of interest in the ROI window.
int countThreshold (const IplImage *frame)
 Returns a threshold computed from the frame.
int recognize (const CvMat *frame)
int modeImage (char *imageFilename)
 Simulates MODE_RECOGNIZE over one specified image filename (PC only).
int modeVideo (CvCapture *capture, CvRect *roi)
 Displays just a real video in a window (only on PC).
int recognizeMode_processKeys (IplImage *frame)
 On PC processes keyboard events, on PPC does nothing.
void displayFrames (IplImage *frame)
int modeRecognize (CvCapture *capture, CvRect *roi)
 Implements the camera recognition of corns configurations.
int waitMode_processKeys (int previousMode)
 Returns mode to switch to from wait mode.
int modeWait (int previousMode)
 Waits until orte.camera_control.on is set to true or, on PC P-key is pressed.
void setAnalyticWindowsVisible (bool visible)
 Sets visibility of 3 analytic windows (threshold, mask and product).
void destroyGUI (void)
 Destroys highgui windows.
int modeManager (int defaultMode, char *paramC)
 Switches between modes of the program.
bool getCameraControlOn (void)
 Returns actual state of orte.camera_control.on.
void send_cmr_res_cb (const ORTESendInfo *info, void *vinstance, void *recvCallBackParam)
 Orte camera result callback function.
void rcv_cmr_ctrl_cb (const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
 Orte camera control callback function.
void rcv_robot_switches_cb (const ORTERecvInfo *info, void *vinstance, void *recvCallBackParam)
 Orte switches control callback function.
int getParamI (int argc, char *argv[], char *imgFilename)
int main (int argc, char *argv[])
 The program may on PC be called with -i argument followed by an image filename, i.e.
int recognize (IplImage *gray_frame)
 Returns an ordinary number of recognized configuration.
void displayFrames (const char *window_name, IplImage *frame)
 Displays analytic frames on screen (on PC), or saves (input) frame to file.
void initGUI (void)
 Initializes GUI, displays static video window.
int getStartMode (int argc, char *argv[], char *imgFilename)
 If "-i filename" is in argv, filename is stored to imgFilename.

Variables

struct robottype_orte_data orte
bool camera_control_on = false
CvFont fontLarge

Define Documentation

#define BARCAM_DEBUG
#define KEY_1   0x31
#define KEY_2   0x32
#define KEY_3   0x33
#define KEY_4   0x34
#define KEY_5   0x35
#define KEY_6   0x36
#define KEY_7   0x37
#define KEY_8   0x38
#define KEY_ESC   0x1B
#define KEY_MINUS   0x2D
#define KEY_O   0x4f
#define KEY_o   0x6f
#define KEY_P   0x50
#define KEY_p   0x70
#define KEY_PLUS   0x2B
#define KEY_R   0x52
#define KEY_r   0x72
#define KEY_S   0x53
#define KEY_s   0x73
#define KEY_SPACE   0x20
#define KEY_V   0x56
#define KEY_v   0x76
#define KEY_W   0x57
#define KEY_w   0x77
#define MODE_IMAGE   0x10
#define MODE_QUIT   0x01
#define MODE_RECOGNIZE   0x04
#define MODE_VIDEO   0x02
#define MODE_WAIT   0x08
#define ROI_HEIGHT   WINDOW_HEIGHT
#define ROI_WIDTH   WINDOW_WIDTH
#define ROI_X   0
#define ROI_Y   0
#define SNAPSHOTFILENAME   "snapshot%02d.png"
#define WINDOW_HEIGHT   480
#define WINDOW_ORIG   "BARCAM original scene"
#define WINDOW_PROD   "BARCAM recognition product"
#define WINDOW_WIDTH   640
#define WITH_GUI

Function Documentation

int countThreshold ( const IplImage *  frame  ) 

Returns a threshold computed from the frame.

Parameters:
frame Frame to compute a threshold from.
Returns:
Mean of all pixels of the frame.

Here is the caller graph for this function:

void destroyGUI ( void   ) 

Destroys highgui windows.

Here is the caller graph for this function:

void displayFrames ( IplImage *  frame  ) 

Here is the caller graph for this function:

void displayFrames ( const char *  window_name,
IplImage *  frame 
)

Displays analytic frames on screen (on PC), or saves (input) frame to file.

Parameters:
frame Input frame from camera.
window_name Name of the window to show frame in.
bool getCameraControlOn ( void   )  [inline]

Returns actual state of orte.camera_control.on.

If value changed from previous call, informative output is printed.

Here is the caller graph for this function:

int getParamI ( int  argc,
char *  argv[],
char *  imgFilename 
)
int getStartMode ( int  argc,
char *  argv[],
char *  imgFilename 
)

If "-i filename" is in argv, filename is stored to imgFilename.

Returns:
Mode to switch to.

Here is the call graph for this function:

Here is the caller graph for this function:

void initGUI ( void   ) 

Initializes GUI, displays static video window.

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

The program may on PC be called with -i argument followed by an image filename, i.e.

rozkuk -i image.png, then the program runs in image mode. Else call it without arguments. On PC it starts in video mode, to switch modes keyboard is used (R-recognize, W-wait, Esc-quit). On PPC only two modes are available - recognize and wait. Orte's camera_control_on variable is used to switch between them.

Here is the call graph for this function:

int modeImage ( char *  imageFilename  ) 

Simulates MODE_RECOGNIZE over one specified image filename (PC only).

Parameters:
imageFilename Image to load and recognize.
Returns:
Code of mode to switch to.

Here is the call graph for this function:

Here is the caller graph for this function:

int modeManager ( int  defaultMode,
char *  paramC 
)

Switches between modes of the program.

Parameters:
defaultMode The first mode to run.
paramC Used only in MODE_IMAGE mode (store filepath here).
Returns:
Zero on success, error number on fail.

Here is the call graph for this function:

Here is the caller graph for this function:

int modeRecognize ( CvCapture *  capture,
CvRect *  roi 
)

Implements the camera recognition of corns configurations.

Parameters:
capture Pointer to a camera capture.
roi Pointer to ROI rectangle.
Returns:
Code of mode to switch to.

Here is the call graph for this function:

Here is the caller graph for this function:

int modeVideo ( CvCapture *  capture,
CvRect *  roi 
)

Displays just a real video in a window (only on PC).

Parameters:
capture Pointer to a camera capture.
roi Pointer to ROI rectangle.
Returns:
Code of mode to switch to.

Here is the call graph for this function:

Here is the caller graph for this function:

int modeWait ( int  previousMode  ) 

Waits until orte.camera_control.on is set to true or, on PC P-key is pressed.

Waits until orte.camera_control.on is set to true or, on PC, W or P key is pressed.

Parameters:
previousMode Mode to switch to when waiting stops.
Returns:
Code of mode to switch to.

Here is the call graph for this function:

Here is the caller graph for this function:

void rcv_cmr_ctrl_cb ( const ORTERecvInfo *  info,
void *  vinstance,
void *  recvCallBackParam 
)

Orte camera control callback function.

Sets actual value of orte.camera_control.on to camera_control_on.

Here is the call graph for this function:

Here is the caller graph for this function:

void rcv_robot_switches_cb ( const ORTERecvInfo *  info,
void *  vinstance,
void *  recvCallBackParam 
)

Orte switches control callback function.

Sets actual value of orte.robot_switches.team_color to robot_switches_color.

Here is the call graph for this function:

Here is the caller graph for this function:

int recognize ( IplImage *  gray_frame  ) 

Returns an ordinary number of recognized configuration.

Parameters:
frame Frame to be processed.
Returns:

Here is the call graph for this function:

int recognize ( const CvMat *  frame  ) 

Here is the caller graph for this function:

int recognizeMode_processKeys ( IplImage *  frame  ) 

On PC processes keyboard events, on PPC does nothing.

Parameters:
frame Last camera frame.
Returns:
MODE_RECOGNIZE or mode to switch to.

Here is the call graph for this function:

Here is the caller graph for this function:

int saveFrame ( const CvArr *  img  ) 

Saves current image to a new file in the current directory.

Parameters:
img Image to save to file.
Returns:
Value returned by cvSaveImage.

Here is the call graph for this function:

Here is the caller graph for this function:

void selectROI ( CvCapture *  capture,
CvRect *  roi 
)

Setting region of interest in the ROI window.

Parameters:
capture Pointer to a camera capture.
roi Pointer to ROI rectangle.

Here is the call graph for this function:

Here is the caller graph for this function:

void send_cmr_res_cb ( const ORTESendInfo *  info,
void *  vinstance,
void *  recvCallBackParam 
)

Orte camera result callback function.

Does nothing.

Here is the caller graph for this function:

void setAnalyticWindowsVisible ( bool  visible  ) 

Sets visibility of 3 analytic windows (threshold, mask and product).

Parameters:
visible Use true to display windows, false to hide.

Here is the caller graph for this function:

int waitMode_processKeys ( int  previousMode  ) 

Returns mode to switch to from wait mode.

On PC processes keyboard events, on PPC just tests for orte.camera_control.on value.

Parameters:
previousMode Mode to switch to, if no more waiting is needed.
Returns:
Mode to switch to.

Here is the caller graph for this function:


Variable Documentation

bool camera_control_on = false
CvFont fontLarge
struct robottype_orte_data orte