#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>
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 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 |
| 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 displayFrames | ( | IplImage * | frame | ) |

| void displayFrames | ( | const char * | window_name, | |
| IplImage * | frame | |||
| ) |
Displays analytic frames on screen (on PC), or saves (input) frame to file.
| 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.

| 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.


| void initGUI | ( | void | ) |
Initializes GUI, displays static video window.

| 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, | |
| CvRect * | roi | |||
| ) |
Implements the camera recognition of corns configurations.
| capture | Pointer to a camera capture. | |
| roi | Pointer to ROI rectangle. |


| int modeVideo | ( | CvCapture * | capture, | |
| CvRect * | roi | |||
| ) |
Displays just a real video in a window (only on PC).
| capture | Pointer to a camera capture. | |
| roi | Pointer to ROI rectangle. |


| 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.
| 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 | ( | IplImage * | gray_frame | ) |
Returns an ordinary number of recognized configuration.
| frame | Frame to be processed. |

| int recognize | ( | const CvMat * | frame | ) |

| 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 selectROI | ( | CvCapture * | capture, | |
| CvRect * | roi | |||
| ) |
Setting region of interest in the ROI window.
| capture | Pointer to a camera capture. | |
| roi | Pointer to ROI rectangle. |


| 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 |
| CvFont fontLarge |
| struct robottype_orte_data orte |
1.7.1