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