00001 #include "ProjectInterface.h"
00002 #include "Wireless/Socket.h"
00003 #include "Vision/SegmentedColorGenerator.h"
00004 #include "debuget.h"
00005 #include <exception>
00006
00007 namespace ProjectInterface {
00008
00009
00010 void noSendCommandErr(const std::string& cmd) {
00011 serr->printf("command '%s' ignored because no ProjectInterface::sendCommand() is installed\n",cmd.c_str());
00012 }
00013 void (*sendCommand)(const std::string& cmd)=noSendCommandErr;
00014
00015 bool displayException(const char * file, int line, const char * message, const std::exception* ex) {
00016 if(file!=NULL) {
00017 serr->printf("Exception caught at %s:%d => ",debuget::extractFilename(file),line);
00018 } else {
00019 serr->printf("Exception => ");
00020 }
00021 if(ex!=NULL) {
00022 serr->printf("'%s'",ex->what());
00023 } else {
00024 serr->printf("'%s'","Unknown type");
00025 }
00026 if(message!=NULL) {
00027 serr->printf(" (%s)\n",message);
00028 } else {
00029 serr->printf("\n");
00030 }
00031 #ifndef PLATFORM_APERIOS
00032 serr->printf("\tWhen running in gdb, try 'catch throw' to break where exceptions are first thrown.\n");
00033 #endif
00034 return true;
00035 }
00036 bool (*uncaughtException)(const char * file, int line, const char * message, const std::exception* ex)=&displayException;
00037
00038
00039 color_index defLookupColorIndexByName(const std::string& name) {
00040 if(defSegmentedColorGenerator==NULL)
00041 return -1U;
00042 return defSegmentedColorGenerator->getColorIndex(name);
00043 }
00044 color_index (*lookupColorIndexByName)(const std::string& name)=&defLookupColorIndexByName;
00045
00046
00047 color_index defLookupColorIndexByRgb(const rgb rgbval) {
00048 if(defSegmentedColorGenerator==NULL)
00049 return -1U;
00050 return defSegmentedColorGenerator->getColorIndex(rgbval);
00051 }
00052
00053 color_index (*lookupColorIndexByRgb)(const rgb rgbval)=&defLookupColorIndexByRgb;
00054
00055
00056 rgb defLookupColorRGB(color_index cindex) {
00057 if(defSegmentedColorGenerator==NULL)
00058 return rgb();
00059 return defSegmentedColorGenerator->getColorRGB(cindex);
00060 }
00061 rgb (*lookupColorRGB)(color_index cindex)=&defLookupColorRGB;
00062
00063
00064 const char* defLookupColorName(color_index cindex) {
00065 if(defSegmentedColorGenerator==NULL)
00066 return NULL;
00067 return defSegmentedColorGenerator->getColorName(cindex);
00068 }
00069 const char* (*lookupColorName)(color_index cindex)=&defLookupColorName;
00070
00071
00072 unsigned int defLookupNumColors() {
00073 if ( defSegmentedColorGenerator == NULL )
00074 return -1U;
00075 return defSegmentedColorGenerator->getNumColors();
00076 }
00077
00078 unsigned int (*lookupNumColors)() = &defLookupNumColors;
00079
00080
00081
00082 FilterBankGenerator * defRawCameraGenerator=NULL;
00083 FilterBankGenerator * defInterleavedYUVGenerator=NULL;
00084 JPEGGenerator * defColorJPEGGenerator=NULL;
00085 JPEGGenerator * defGrayscaleJPEGGenerator=NULL;
00086 PNGGenerator * defColorPNGGenerator=NULL;
00087 PNGGenerator * defGrayscalePNGGenerator=NULL;
00088 SegmentedColorGenerator * defSegmentedColorGenerator=NULL;
00089 RLEGenerator * defRLEGenerator=NULL;
00090 RegionGenerator * defRegionGenerator=NULL;
00091
00092
00093
00094 unsigned int visRawCameraSID=0;
00095
00096 unsigned int visInterleaveSID=0;
00097
00098 unsigned int visColorJPEGSID=0;
00099 unsigned int visGrayscaleJPEGSID=1;
00100
00101 unsigned int visColorPNGSID=0;
00102 unsigned int visGrayscalePNGSID=1;
00103
00104 unsigned int visSegmentSID=0;
00105
00106 unsigned int visRLESID=0;
00107
00108 unsigned int visRegionSID=0;
00109
00110 unsigned int visPinkBallSID=0;
00111 unsigned int visBlueBallSID=1;
00112 unsigned int visGreenBallSID=2;
00113 unsigned int visYellowBallSID=3;
00114 unsigned int visOrangeSID=4;
00115 unsigned int visHandSID=visOrangeSID;
00116
00117
00118
00119 unsigned int doubleLayer=5;
00120 unsigned int fullLayer=4;
00121 unsigned int halfLayer=3;
00122 unsigned int quarterLayer=2;
00123 unsigned int eighthLayer=1;
00124 unsigned int sixteenthLayer=0;
00125
00126 }
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138