#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>
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 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 |
int countThreshold | ( | const IplImage * | frame | ) |
Returns a threshold computed from the frame.
frame | Frame to compute a threshold from. |
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.
floatMat | Pointer to matrix data to display. | |
windowName | Name of window in which to display the image. |
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).
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.
mat1 | First float matrix. | |
mat2 | Second float matrix. | |
windowName | Window specifier. |
void displayProduct | ( | const CvMat * | floatMat, | |
int | sideConfig, | |||
int | centerConfig | |||
) |
Displays in product window the result of multiplying camera frame (in float) and recognized mask.
floatMat | Pointer to the camera frame converted to float matrix. | |
sideConfig | Index of recognized side situation. | |
centerConfig | Index of recognized center situation. |
void drawPauseText | ( | IplImage * | img | ) |
Writes text "pause" in the CAMERA window.
img | Frame to display with PAUSE text. |
void freeMasks | ( | void | ) |
Frees the memory allocated for masks.
bool getCameraControlOn | ( | void | ) |
Returns actual state of orte.camera_control.on.
If value changed from previous call, informative output is printed.
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.
int getStartMode | ( | int | argc, | |
char * | argv[], | |||
char * | imgFilename | |||
) |
If "-i filename" is in argv, filename is stored to imgFilename.
void initGUI | ( | void | ) |
Initializes GUI, displays static video window.
int loadMask | ( | const char * | filename, | |
CvMat ** | mask | |||
) |
Loads binary (float) data to *mask from file.
filename | Path to file to read. | |
mask | Address of array, where to alloc memory and store the data. |
int loadMasks | ( | char | color | ) |
Loads all the float masks from files.
color | Actual team color - use 'b' or 'y'. |
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.
int modeImage | ( | char * | imageFilename | ) |
Simulates MODE_RECOGNIZE over one specified image filename (PC only).
imageFilename | Image to load and recognize. |
int modeManager | ( | int | defaultMode, | |
char * | paramC | |||
) |
Switches between modes of the program.
defaultMode | The first mode to run. | |
paramC | Used only in MODE_IMAGE mode (store filepath here). |
int modeRecognize | ( | CvCapture * | capture, | |
CORBA_octet | currentColor | |||
) |
Implements the camera recognition of corns configurations.
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). |
int modeVideo | ( | CvCapture * | capture | ) |
Displays just a real video in a window (only on PC).
capture | Pointer to a camera capture. |
int modeWait | ( | int | previousMode | ) |
Waits until orte.camera_control.on is set to true or, on PC, W or P key is pressed.
previousMode | Mode to switch to when waiting stops. |
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.
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.
int recognize | ( | const CvMat * | frame, | |
CvMat ** | masks, | |||
int | masksCnt, | |||
double * | resDist | |||
) |
Returns an ordinary number of recognized configuration.
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. |
int recognizeMode_processKeys | ( | IplImage * | frame | ) |
On PC processes keyboard events, on PPC does nothing.
frame | Last camera frame. |
int saveFrame | ( | const CvArr * | img | ) |
Saves current image to a new file in the current directory.
img | Image to save to file. |
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).
visible | Use true to display windows, false to hide. |
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.
previousMode | Mode to switch to, if no more waiting is needed. |
bool camera_control_on = false |
CvMat** centerMasks = NULL |
CvFont fontLarge |
struct robottype_orte_data orte |
CORBA_octet robot_switches_color = 100 |
CvMat** sideMasks = NULL |