Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
ASCIIVisionBehavior.ccGo to the documentation of this file.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+1] = 00007 " .,-+=ioxwfkHN8M#@"; 00008 00009 00010 void 00011 ASCIIVisionBehavior::processEvent(const EventBase& e) { 00012 const FilterBankEvent& fbkevt=dynamic_cast<const FilterBankEvent&>(e); 00013 00014 unsigned int layer = 2; 00015 00016 char charimg[(fbkevt.getWidth(layer)+1)*fbkevt.getHeight(layer)+1]; 00017 char * curchar=charimg; 00018 unsigned char * image = fbkevt.getImage(layer, RawCameraGenerator::CHAN_Y); 00019 for (unsigned int y = 0; y < fbkevt.getHeight(layer); y+=2) { 00020 //notice 'y+=2' above -- skip every other row, makes "image" look more square (letters are taller than wide) 00021 //normally, if you want to process every pixel, use y++ instead ;) 00022 unsigned char * row = image + (y * fbkevt.getStride(layer)); 00023 for (unsigned int x = 0; x < fbkevt.getWidth(layer); x++) { 00024 unsigned char * pixel = row + (x * fbkevt.getIncrement(layer)); 00025 *curchar++=charMap[(pixel[0]*charMapSize)/256]; 00026 } 00027 *curchar++='\n'; 00028 } 00029 *curchar='\0'; 00030 00031 sout->printf("\n\n%s",charimg); 00032 } 00033 00034 /*! @file 00035 * @brief Implements ASCIIVisionBehavior, which streams low-resolution ASCII-art of the camera image to sout 00036 * @author ejt (Creator) 00037 * 00038 * $Author: ejt $ 00039 * $Name: tekkotsu-2_4_1 $ 00040 * $Revision: 1.4 $ 00041 * $State: Exp $ 00042 * $Date: 2005/06/01 05:47:45 $ 00043 */ |
Tekkotsu v2.4.1 |
Generated Tue Aug 16 16:32:45 2005 by Doxygen 1.4.4 |