00001
00002
00003
00004
00005
00006
00007
00008 #ifdef NEWDEBUGGING
00009 #include "DebugImages2.h"
00010 #else
00011 #ifndef __DebugImages_h_
00012 #define __DebugImages_h_
00013
00014 #include "Tools/Debugging/Debugging.h"
00015
00016 #ifdef NDEBUG
00017 #define NODEBUGDRAWINGS
00018 #endif
00019 #ifdef NO_DEBUG_DRAWING
00020 #define NODEBUGDRAWINGS
00021 #endif
00022
00023 #ifdef NODEBUGDRAWINGS
00024 #define DECLARE_DEBUG_COLOR_CLASS_IMAGE(id)
00025 #define SEND_DEBUG_COLOR_CLASS_IMAGE(id)
00026 #else //NODEBUGDRAWINGS
00027
00028
00029
00030
00031 #define DECLARE_DEBUG_COLOR_CLASS_IMAGE(id) ColorClassImage id##ColorClassImage
00032
00033
00034 #define SEND_DEBUG_COLOR_CLASS_IMAGE(id) INFO(send_##id##_image, idDebugColorClassImage, bin, Images::id << id##ColorClassImage)
00035
00036 #endif //NODEBUGDRAWINGS
00037
00038
00039 #if defined(_WIN32)
00040
00041
00042
00043
00044
00045 #define DECLARE_DEBUG_IMAGE(id) Image id##Image
00046
00047
00048
00049
00050
00051
00052 #define INIT_DEBUG_IMAGE(id, image) id##Image = image
00053
00054
00055
00056
00057
00058 #define GENERATE_DEBUG_IMAGE(id,expression) \
00059 if (getDebugKeyTable().isActive(DebugKeyTable::send_##id##_image)) {\
00060 expression;\
00061 }
00062
00063
00064 #define SEND_DEBUG_IMAGE(id) INFO(send_##id##_image, idDebugImage, bin, Images::id << id##Image)
00065
00066
00067 #define DEBUG_IMAGE_SET_PIXEL_Y(id, xx, yy, y) \
00068 { \
00069 if(xx >= 0 && xx < id##Image.cameraInfo.resolutionWidth && \
00070 yy >= 0 && yy < id##Image.cameraInfo.resolutionHeight) \
00071 id##Image.image[yy][0][xx] = y; \
00072 }
00073
00074
00075 #define DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, y, u, v) \
00076 { \
00077 if(xx >= 0 && xx < id##Image.cameraInfo.resolutionWidth && \
00078 yy >= 0 && yy < id##Image.cameraInfo.resolutionHeight) \
00079 { \
00080 id##Image.image[yy][0][xx] = y; \
00081 id##Image.image[yy][1][xx] = u; \
00082 id##Image.image[yy][2][xx] = v; \
00083 } \
00084 }
00085
00086 #define DEBUG_IMAGE_GET_PIXEL_Y(id, xx, yy) id##Image.image[yy][0][xx]
00087 #define DEBUG_IMAGE_GET_PIXEL_U(id, xx, yy) id##Image.image[yy][1][xx]
00088 #define DEBUG_IMAGE_GET_PIXEL_V(id, xx, yy) id##Image.image[yy][2][xx]
00089
00090
00091 #define DEBUG_IMAGE_SET_PIXEL_BLACK(id, xx, yy)\
00092 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 0, 127, 127)
00093
00094 #define DEBUG_IMAGE_SET_PIXEL_WHITE(id, xx, yy)\
00095 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 255, 127, 127)
00096
00097 #define DEBUG_IMAGE_SET_PIXEL_GREEN(id, xx, yy)\
00098 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 180, 0, 0)
00099
00100 #define DEBUG_IMAGE_SET_PIXEL_LIGHT_GRAY(id, xx, yy)\
00101 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 192, 127, 127)
00102
00103 #define DEBUG_IMAGE_SET_PIXEL_GRAY(id, xx, yy)\
00104 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 127, 127, 127)
00105
00106 #define DEBUG_IMAGE_SET_PIXEL_DARK_GRAY(id, xx, yy)\
00107 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 64, 127, 127)
00108
00109 #define DEBUG_IMAGE_SET_PIXEL_DARK_GREEN(id, xx, yy)\
00110 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 0, 0, 0)
00111
00112 #define DEBUG_IMAGE_SET_PIXEL_ORANGE(id, xx, yy)\
00113 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 100, 255, 0)
00114
00115 #define DEBUG_IMAGE_SET_PIXEL_YELLOW(id, xx, yy)\
00116 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 180, 255, 0)
00117
00118 #define DEBUG_IMAGE_SET_PIXEL_RED(id, xx, yy)\
00119 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 0, 255, 0)
00120
00121 #define DEBUG_IMAGE_SET_PIXEL_MAUVE(id, xx, yy)\
00122 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 0, 180, 255)
00123
00124 #define DEBUG_IMAGE_SET_PIXEL_BLUE(id, xx, yy)\
00125 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 180, 0, 255)
00126
00127 #define DEBUG_IMAGE_SET_PIXEL_PINK(id, xx, yy)\
00128 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 255, 255, 255)
00129
00130 #define DEBUG_IMAGE_SET_PIXEL_DARK_BLUE(id, xx, yy)\
00131 DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, 100, 0, 255)
00132
00133 #else //_WIN32
00134
00135 #ifdef __GNUC__
00136 #define DECLARE_DEBUG_IMAGE(id)
00137 #else
00138 #define DECLARE_DEBUG_IMAGE(id) static bool id##Dummy
00139 #endif
00140 #define INIT_DEBUG_IMAGE(id, image)
00141 #define GENERATE_DEBUG_IMAGE(id,expression)
00142 #define SEND_DEBUG_IMAGE(id)
00143 #define DEBUG_IMAGE_SET_PIXEL_Y(id, xx, yy, y)
00144 #define DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, y, u, v)
00145 #define DEBUG_IMAGE_SET_PIXEL_BLACK(id, xx, yy)
00146 #define DEBUG_IMAGE_SET_PIXEL_WHITE(id, xx, yy)
00147 #define DEBUG_IMAGE_SET_PIXEL_GREEN(id, xx, yy)
00148 #define DEBUG_IMAGE_SET_PIXEL_GRAY(id, xx, yy)
00149 #define DEBUG_IMAGE_SET_PIXEL_LIGHT_GRAY(id, xx, yy)
00150 #define DEBUG_IMAGE_SET_PIXEL_DARK_GRAY(id, xx, yy)
00151 #define DEBUG_IMAGE_SET_PIXEL_DARK_GREEN(id, xx, yy)
00152 #define DEBUG_IMAGE_SET_PIXEL_ORANGE(id, xx, yy)
00153 #define DEBUG_IMAGE_SET_PIXEL_YELLOW(id, xx, yy)
00154 #define DEBUG_IMAGE_SET_PIXEL_RED(id, xx, yy)
00155 #define DEBUG_IMAGE_SET_PIXEL_MAUVE(id, xx, yy)
00156 #define DEBUG_IMAGE_SET_PIXEL_BLUE(id, xx, yy)
00157 #define DEBUG_IMAGE_SET_PIXEL_PINK(id, xx, yy)
00158 #define DEBUG_IMAGE_SET_PIXEL_DARK_BLUE(id, xx, yy)
00159 #define DEBUG_IMAGE_GET_PIXEL_Y(id, xx, yy) 0
00160 #define DEBUG_IMAGE_GET_PIXEL_U(id, xx, yy) 0
00161 #define DEBUG_IMAGE_GET_PIXEL_V(id, xx, yy) 0
00162
00163 #endif //_WIN32
00164
00165
00166
00167
00168
00169 class Images
00170 {
00171 public:
00172
00173
00174
00175
00176 enum ImageID
00177 {
00178 noImage,
00179 rawImage,
00180 segmentedImage1,
00181 segmentedImage2,
00182 segmentedImage3,
00183 classificationY,
00184 classificationU,
00185 classificationV,
00186 colorFrequency,
00187 imageProcessorGeneral,
00188 imageProcessorScanLines,
00189 imageProcessorBall,
00190 imageProcessorGoal1,
00191 imageProcessorGoal2,
00192 imageProcessorFlags,
00193 imageProcessorPlayers,
00194 imageProcessorGradients,
00195 imageMotionRecognition,
00196 imageProcessorRobotDetection,
00197 numberOfImageIDs,
00198 image = numberOfImageIDs,
00199 segmentedImage,
00200 correctedImage,
00201 correctedSegmentedImage,
00202
00203 imageProcessorGoals = imageProcessorGoal1
00204 };
00205
00206
00207
00208
00209
00210 static char* getImageIDName(ImageID imageID)
00211 {
00212 switch (imageID)
00213 {
00214 case noImage: return "no image";
00215 case rawImage: return "raw image";
00216 case segmentedImage1: return "segmented image 1";
00217 case segmentedImage2: return "segmented image 2";
00218 case segmentedImage3: return "segmented image 3";
00219 case classificationY: return "classificationY";
00220 case classificationU: return "classificationU";
00221 case classificationV: return "classificationV";
00222 case colorFrequency: return "colorFrequency";
00223 case imageProcessorGeneral: return "imageProcessorGeneral";
00224 case imageProcessorScanLines: return "imageProcessorScanLines";
00225 case imageProcessorBall: return "imageProcessorBall";
00226 case imageProcessorFlags: return "imageProcessorFlags";
00227 case imageProcessorGoal1: return "imageProcessorGoal1";
00228 case imageProcessorGoal2: return "imageProcessorGoal2";
00229 case imageProcessorPlayers: return "imageProcessorPlayers";
00230 case imageProcessorGradients: return "imageProcessorGradients";
00231 case imageMotionRecognition: return "imageMotionRecognition";
00232 case imageProcessorRobotDetection: return "imageProcessorRobotDetection";
00233 default: return "check available drawings";
00234 }
00235 }
00236
00237 static bool getDebugKeyID(enum ImageID imageID, DebugKeyTable::debugKeyID& debugKeyID)
00238 {
00239 switch (imageID)
00240 {
00241 case segmentedImage1: debugKeyID = DebugKeyTable::send_segmentedImage1_image; return true;
00242 case segmentedImage2: debugKeyID = DebugKeyTable::send_segmentedImage2_image; return true;
00243 case segmentedImage3: debugKeyID = DebugKeyTable::send_segmentedImage3_image; return true;
00244 case classificationY: debugKeyID = DebugKeyTable::send_classificationY_image; return true;
00245 case classificationU: debugKeyID = DebugKeyTable::send_classificationU_image; return true;
00246 case classificationV: debugKeyID = DebugKeyTable::send_classificationV_image; return true;
00247 case colorFrequency: debugKeyID = DebugKeyTable::send_colorFrequency_image; return true;
00248 case imageProcessorGeneral: debugKeyID = DebugKeyTable::send_imageProcessorGeneral_image; return true;
00249 case imageProcessorScanLines: debugKeyID = DebugKeyTable::send_imageProcessorScanLines_image; return true;
00250 case imageProcessorBall: debugKeyID = DebugKeyTable::send_imageProcessorBall_image; return true;
00251 case imageProcessorFlags: debugKeyID = DebugKeyTable::send_imageProcessorFlags_image; return true;
00252 case imageProcessorGoal1: debugKeyID = DebugKeyTable::send_imageProcessorGoal1_image; return true;
00253 case imageProcessorGoal2: debugKeyID = DebugKeyTable::send_imageProcessorGoal2_image; return true;
00254 case imageProcessorPlayers: debugKeyID = DebugKeyTable::send_imageProcessorPlayers_image; return true;
00255 case imageProcessorGradients: debugKeyID = DebugKeyTable::send_imageProcessorGradients_image; return true;
00256 case imageMotionRecognition: debugKeyID = DebugKeyTable::send_imageMotionRecognition_image; return true;
00257 case imageProcessorRobotDetection: debugKeyID = DebugKeyTable::send_imageProcessorRobotDetection_image; return true;
00258
00259 default: return false;
00260 }
00261 }
00262 };
00263
00264
00265
00266 #define N_DECLARE_DEBUG_IMAGE(id)
00267 #define N_INIT_DEBUG_IMAGE(id, image)
00268 #define N_INIT_DEBUG_IMAGE_BLACK(id, image)
00269 #define N_SEND_DEBUG_IMAGE(id)
00270 #define N_SEND_DEBUG_IMAGE_AS_JPEG(id)
00271 #define N_SEND_DEBUG_IMAGE_AS_JPEG2(id)
00272 #define N_DEBUG_IMAGE_SET_PIXEL_YUV(id, xx, yy, y, u, v)
00273 #define N_DEBUG_IMAGE_GET_PIXEL_Y(id, xx, yy)
00274 #define N_DEBUG_IMAGE_GET_PIXEL_U(id, xx, yy)
00275 #define N_DEBUG_IMAGE_GET_PIXEL_V(id, xx, yy)
00276 #define N_DEBUG_IMAGE_SET_PIXEL_BLACK(id, xx, yy)
00277 #define N_DEBUG_IMAGE_SET_PIXEL_WHITE(id, xx, yy)
00278 #define N_DEBUG_IMAGE_SET_PIXEL_GREEN(id, xx, yy)
00279 #define N_DEBUG_IMAGE_SET_PIXEL_LIGHT_GRAY(id, xx, yy)
00280 #define N_DEBUG_IMAGE_SET_PIXEL_GRAY(id, xx, yy)
00281 #define N_DEBUG_IMAGE_SET_PIXEL_DARK_GRAY(id, xx, yy)
00282 #define N_DEBUG_IMAGE_SET_PIXEL_DARK_GREEN(id, xx, yy)
00283 #define N_DEBUG_IMAGE_SET_PIXEL_ORANGE(id, xx, yy)
00284 #define N_DEBUG_IMAGE_SET_PIXEL_YELLOW(id, xx, yy)
00285 #define N_DEBUG_IMAGE_SET_PIXEL_RED(id, xx, yy)
00286 #define N_DEBUG_IMAGE_SET_PIXEL_MAUVE(id, xx, yy)
00287 #define N_DEBUG_IMAGE_SET_PIXEL_BLUE(id, xx, yy)
00288 #define N_DEBUG_IMAGE_SET_PIXEL_PINK(id, xx, yy)
00289 #define N_DEBUG_IMAGE_SET_PIXEL_DARK_BLUE(id, xx, yy)
00290
00291
00292 #define N_DECLARE_DEBUG_GRAY_SCALE_IMAGE(id)
00293 #define N_INIT_DEBUG_GRAY_SCALE_IMAGE(id, image)
00294 #define N_SET_COLORED_PIXEL_IN_GRAY_SCALE_IMAGE(id, x, y, color)
00295 #define N_SEND_DEBUG_GRAY_SCALE_IMAGE(id)
00296
00297
00298 #define N_DECLARE_DEBUG_COLOR_CLASS_IMAGE(id)
00299 #define N_SEND_DEBUG_COLOR_CLASS_IMAGE(id)
00300
00301
00302 #define N_GENERATE_DEBUG_IMAGE(id,expression)
00303
00304 #endif //__DebugImages_h_
00305 #endif //NEWDEBUGGING