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