00001 #include "ASCIIVisionBehavior.h"
00002 #include "Events/FilterBankEvent.h"
00003 #include "Vision/RawCameraGenerator.h"
00004 #include "Wireless/Socket.h"
00005
00006 const char ASCIIVisionBehavior::charMap[ASCIIVisionBehavior::charMapSize] = {
00007 ' ','.',',','\'','~','-','"','^',':',';','!','i','l','I','>','+','?',')',
00008 '1',']','|','/','t','f','j','r','n','u','v','c','z','x','Y','U','J','C','L','Q',
00009 '0','O','Z','X','m','w','q','p','d','b','k','h','a','o','*','#','M','W','&','8',
00010 '%','B','$','@'
00011 };
00012
00013
00014 void
00015 ASCIIVisionBehavior::processEvent(const EventBase& e) {
00016 const FilterBankEvent& fbkevt=dynamic_cast<const FilterBankEvent&>(e);
00017
00018 unsigned int layer = 1;
00019
00020 char charimg[(fbkevt.getWidth(layer)+1)*fbkevt.getHeight(layer)+1];
00021 char * curchar=charimg;
00022 unsigned char * image = fbkevt.getImage(layer, RawCameraGenerator::CHAN_Y);
00023 for (unsigned int y = 0; y < fbkevt.getHeight(layer); y++) {
00024 unsigned char * row = image + (y * fbkevt.getStride(layer));
00025 for (unsigned int x = 0; x < fbkevt.getWidth(layer); x++) {
00026 unsigned char * pixel = row + (x * fbkevt.getIncrement(layer));
00027 *curchar++=charMap[(pixel[0]*charMapSize)/256];
00028 }
00029 *curchar++='\n';
00030 }
00031 *curchar='\0';
00032
00033 sout->printf("\n\n%s",charimg);
00034 }
00035