00001 #include "StartupBehavior.h"
00002
00003 #include "Shared/ProjectInterface.h"
00004 #include "Shared/Config.h"
00005
00006 #include "Behaviors/Controls/BehaviorSwitchControl.h"
00007
00008 #include "Vision/RawCameraGenerator.h"
00009 #include "Vision/InterleavedYUVGenerator.h"
00010 #include "Vision/JPEGGenerator.h"
00011 #include "Vision/SegmentedColorGenerator.h"
00012 #include "Vision/RLEGenerator.h"
00013 #include "Vision/RegionGenerator.h"
00014 #include "Vision/BallDetectionGenerator.h"
00015 #include "Vision/CDTGenerator.h"
00016
00017 using namespace ProjectInterface;
00018
00019 BallDetectionGenerator * pball=NULL;
00020 BallDetectionGenerator * bball=NULL;
00021 BallDetectionGenerator * handball=NULL;
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 void
00032 StartupBehavior::initVision() {
00033
00034
00035 unsigned int numLayers=6;
00036
00037
00038
00039
00040 unsigned int numSystemLayers=3;
00041
00042 defRawCameraGenerator = new RawCameraGenerator(numSystemLayers,numLayers,EventBase::visOFbkEGID,0,visRawCameraSID);
00043
00044 defInterleavedYUVGenerator = new InterleavedYUVGenerator(EventBase::visRawCameraEGID,visRawCameraSID,visInterleaveSID,RawCameraGenerator::CHAN_Y,RawCameraGenerator::CHAN_U,RawCameraGenerator::CHAN_V);
00045
00046 defColorJPEGGenerator = new JPEGGenerator(EventBase::visInterleaveEGID,visInterleaveSID,visColorJPEGSID,JPEGGenerator::SRC_AUTO);
00047 defColorJPEGGenerator->setName("ColorJPEGGenerator");
00048
00049 defGrayscaleJPEGGenerator = new JPEGGenerator(EventBase::visRawCameraEGID,visRawCameraSID,visGrayscaleJPEGSID,JPEGGenerator::SRC_AUTO);
00050 defGrayscaleJPEGGenerator->setName("GrayscaleJPEGGenerator");
00051
00052
00053
00054
00055
00056 SegmentedColorGenerator * segcol = new SegmentedColorGenerator(EventBase::visRawCameraEGID,visRawCameraSID,visSegmentSID);
00057 defSegmentedColorGenerator = segcol;
00058 segcol->loadColorInfo(config->vision.colors);
00059 for(unsigned int i=0; i<config->vision.thresh.size(); i++)
00060 segcol->loadThresholdMap(config->vision.thresh[i]);
00061
00062 defRLEGenerator = new RLEGenerator(EventBase::visSegmentEGID,visSegmentSID,visRLESID);
00063
00064 defRegionGenerator = new RegionGenerator(EventBase::visRLEEGID,visRLESID,visRegionSID);
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 unsigned int threshChan=config->vision.rlecam_channel;
00076
00077
00078 unsigned int noiseFiltering=1;
00079
00080
00081 float confidenceThreshold=.8;
00082
00083 unsigned int pinkIdx=segcol->getColorIndex("red");
00084 if(pinkIdx!=-1U) {
00085 pball = new BallDetectionGenerator(EventBase::visRegionEGID,visRegionSID,visPinkBallSID,pinkIdx,threshChan,noiseFiltering,confidenceThreshold);
00086 pball->setName("PinkBallDetectionGenerator");
00087 }
00088 unsigned int blueIdx=segcol->getColorIndex("blue");
00089 if(blueIdx!=-1U) {
00090 bball = new BallDetectionGenerator(EventBase::visRegionEGID,visRegionSID,visBlueBallSID,blueIdx,threshChan,noiseFiltering,confidenceThreshold);
00091 bball->setName("BlueBallDetectionGenerator");
00092 }
00093 unsigned int skinIdx=segcol->getColorIndex("brown");
00094 if(skinIdx!=-1U) {
00095 handball = new BallDetectionGenerator(EventBase::visRegionEGID,visRegionSID,visHandSID,skinIdx,threshChan,noiseFiltering,confidenceThreshold);
00096 handball->setName("HandBallDetectionGenerator");
00097 }
00098 }
00099
00100 ControlBase*
00101 StartupBehavior::SetupVision() {
00102 addItem(new ControlBase("Vision Pipeline","Start/Stop stages of the vision pipeline"));
00103 startSubMenu();
00104 {
00105 addItem((new BehaviorSwitchControlBase(defRawCameraGenerator))->start());
00106 addItem((new BehaviorSwitchControlBase(defInterleavedYUVGenerator))->start());
00107 addItem((new BehaviorSwitchControlBase(defColorJPEGGenerator))->start());
00108 addItem((new BehaviorSwitchControlBase(defGrayscaleJPEGGenerator))->start());
00109 if(config->vision.colors!="" && config->vision.thresh.size()>0)
00110 addItem((new BehaviorSwitchControlBase(defSegmentedColorGenerator))->start());
00111 else
00112 addItem(new BehaviorSwitchControlBase(defSegmentedColorGenerator));
00113 addItem((new BehaviorSwitchControlBase(defRLEGenerator))->start());
00114 addItem((new BehaviorSwitchControlBase(defRegionGenerator))->start());
00115 addItem((new BehaviorSwitchControlBase(pball))->start());
00116 addItem((new BehaviorSwitchControlBase(bball))->start());
00117 addItem((new BehaviorSwitchControlBase(handball))->start());
00118 }
00119 return endSubMenu();
00120 }