Defines | Functions | Variables

rozkuk.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 <opencv/cv.h>
#include <opencv/highgui.h>
#include "clr2float.h"
#include "masks_globals.h"
#include "t_decision_box.h"
#include <roboorte_robottype.h>
#include <robot.h>
Include dependency graph for rozkuk.cxx:

Defines

#define MODE_QUIT   0x01
#define MODE_VIDEO   0x02
#define MODE_RECOGNIZE   0x04
#define MODE_WAIT   0x08
#define MODE_IMAGE   0x10
#define WINDOW_ORIG   "ROZKUK original scene"
#define WINDOW_THRES   "ROZKUK threshold"
#define WINDOW_MASK   "ROZKUK mask"
#define WINDOW_PROD   "ROZKUK product"
#define WINDOW_WIDTH   640
#define WINDOW_HEIGHT   480
#define KEY_ESC   0x1B
#define KEY_SPACE   0x20
#define KEY_P   0x50
#define KEY_R   0x52
#define KEY_S   0x53
#define KEY_V   0x56
#define KEY_W   0x57
#define KEY_p   0x70
#define KEY_r   0x72
#define KEY_s   0x73
#define KEY_v   0x76
#define KEY_w   0x77
#define KEY_PLUS   -0x55
#define KEY_MINUS   -0x53
#define SATURATION   1.0
#define THRESHOLD_SHIFT   -25
#define SNAPSHOTFILENAME   "snapshot%02d.pnm"
#define DECISION_BOX_SIZE   3

Functions

int saveFrame (const CvArr *img)
 Saves current image to a new file in the current directory.
void displayProduct (const CvMat *floatMat, int sideConfig, int centerConfig)
 Displays in product window the result of multiplying camera frame (in float) and recognized mask.
void displayMatSum (const CvMat *mat1, const CvMat *mat2, const char *windowName)
 Displays a sum of two matrices in specified window.
void displayFloatMat (const CvMat *floatMat, const char *windowName)
 Normalizes the matrix values and displays them in window specified by name.
int countThreshold (const IplImage *frame)
 Returns a threshold computed from the frame.
int recognize (const CvMat *frame, CvMat **masks, int masksCnt, double *resDist)
 Returns an ordinary number of recognized configuration.
int modeImage (char *imageFilename)
 Simulates MODE_RECOGNIZE over one specified image filename (PC only).
void drawPauseText (IplImage *img)
 Writes text "pause" in the CAMERA window.
int modeVideo (CvCapture *capture)
 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, IplImage **thrFrame, CvMat *fMat, int cfgSide, int cfgCenter)
 Displays analytic frames on screen (on PC), or saves (input) frame to file (on PPC in debug mode).
int modeRecognize (CvCapture *capture, CORBA_octet currentColor)
 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, W or 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.
int loadMask (const char *filename, CvMat **mask)
 Loads binary (float) data to *mask from file.
int loadMasks (char color)
 Loads all the float masks from files.
void freeMasks (void)
 Frees the memory allocated for masks.
bool getCameraControlOn (void)
 Returns actual state of orte.camera_control.on.
CORBA_octet getRobotSwitchesColor (void)
 Returns actual state of orte.robot_switches.team_color.
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.
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
CORBA_octet robot_switches_color = 100
bool camera_control_on = false
CvMat ** sideMasks = NULL
CvMat ** centerMasks = NULL
CvFont fontLarge

Define Documentation

#define DECISION_BOX_SIZE   3
#define KEY_ESC   0x1B
#define KEY_MINUS   -0x53
#define KEY_p   0x70
#define KEY_P   0x50
#define KEY_PLUS   -0x55
#define KEY_r   0x72
#define KEY_R   0x52
#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 SATURATION   1.0
#define SNAPSHOTFILENAME   "snapshot%02d.pnm"
#define THRESHOLD_SHIFT   -25
#define WINDOW_HEIGHT   480
#define WINDOW_MASK   "ROZKUK mask"
#define WINDOW_ORIG   "ROZKUK original scene"
#define WINDOW_PROD   "ROZKUK product"
#define WINDOW_THRES   "ROZKUK threshold"
#define WINDOW_WIDTH   640

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.
void destroyGUI ( void   ) 

Destroys highgui windows.

void displayFloatMat ( const CvMat *  floatMat,
const char *  windowName 
)

Normalizes the matrix values and displays them in window specified by name.

Parameters:
floatMat Pointer to matrix data to display.
windowName Name of window in which to display the image.

Here is the caller graph for this function:

void displayFrames ( IplImage *  frame,
IplImage **  thrFrame,
CvMat *  fMat,
int  cfgSide,
int  cfgCenter 
)

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

Parameters:
frame Input frame from camera.
thrFrame Thresholded frame.
fMat Float representation of frame.
cfgSide Index of current side configuration.
cfgCenter Index of current center configuration.
void displayMatSum ( const CvMat *  mat1,
const CvMat *  mat2,
const char *  windowName 
)

Displays a sum of two matrices in specified window.

Parameters:
mat1 First float matrix.
mat2 Second float matrix.
windowName Window specifier.

Here is the call graph for this function:

Here is the caller graph for this function:

void displayProduct ( const CvMat *  floatMat,
int  sideConfig,
int  centerConfig 
)

Displays in product window the result of multiplying camera frame (in float) and recognized mask.

Parameters:
floatMat Pointer to the camera frame converted to float matrix.
sideConfig Index of recognized side situation.
centerConfig Index of recognized center situation.

Here is the call graph for this function:

void drawPauseText ( IplImage *  img  ) 

Writes text "pause" in the CAMERA window.

Parameters:
img Frame to display with PAUSE text.
void freeMasks ( void   ) 

Frees the memory allocated for masks.

Here is the caller graph for this function:

bool getCameraControlOn ( void   ) 

Returns actual state of orte.camera_control.on.

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

Here is the call graph for this function:

int getParamI ( int  argc,
char *  argv[],
char *  imgFilename 
)
CORBA_octet getRobotSwitchesColor ( void   )  [inline]

Returns actual state of orte.robot_switches.team_color.

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

Returns:
Actual team color.

Here is the call graph for this function:

Here is the caller graph for this function:

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

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

Returns:
Mode to switch to.
void initGUI ( void   ) 

Initializes GUI, displays static video window.

int loadMask ( const char *  filename,
CvMat **  mask 
)

Loads binary (float) data to *mask from file.

Parameters:
filename Path to file to read.
mask Address of array, where to alloc memory and store the data.
Returns:
Length of read data or zero in case of error.

Here is the call graph for this function:

Here is the caller graph for this function:

int loadMasks ( char  color  ) 

Loads all the float masks from files.

Parameters:
color Actual team color - use 'b' or 'y'.
Returns:
Zero if ok, else non-zero.

Here is the call graph for this function:

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:

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:

int modeRecognize ( CvCapture *  capture,
CORBA_octet  currentColor 
)

Implements the camera recognition of corns configurations.

Parameters:
capture Pointer to a camera capture.
currentColor Number of starting color. If it changes in orte during recognition, this mode needs to restart (to load suitable masks).
Returns:
Code of mode to switch to.

Here is the call graph for this function:

int modeVideo ( CvCapture *  capture  ) 

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

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

Here is the call graph for this function:

int modeWait ( int  previousMode  ) 

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:

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:

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:

int recognize ( const CvMat *  frame,
CvMat **  masks,
int  masksCnt,
double *  resDist 
)

Returns an ordinary number of recognized configuration.

Parameters:
frame Float representation of frame.
masks Array of masks to compare with.
masksCnt Size of the array.
resDist If not NULL, a distance between the best and second best result is stored here.
Returns:
Number of recognized configuration.
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.
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:

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

Orte camera result callback function.

Does nothing.

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 call graph for this function:


Variable Documentation

bool camera_control_on = false
CvMat** centerMasks = NULL
CvFont fontLarge
struct robottype_orte_data orte
CORBA_octet robot_switches_color = 100
CvMat** sideMasks = NULL