00001 /*!@file BeoSub/test-ColorTracker.C Test ColorTracker test module */ 00002 00003 // //////////////////////////////////////////////////////////////////// // 00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2001 by the // 00005 // University of Southern California (USC) and the iLab at USC. // 00006 // See http://iLab.usc.edu for information about this project. // 00007 // //////////////////////////////////////////////////////////////////// // 00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected // 00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency // 00010 // in Visual Environments, and Applications'' by Christof Koch and // 00011 // Laurent Itti, California Institute of Technology, 2001 (patent // 00012 // pending; application number 09/912,225 filed July 23, 2001; see // 00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status). // 00014 // //////////////////////////////////////////////////////////////////// // 00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit. // 00016 // // 00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can // 00018 // redistribute it and/or modify it under the terms of the GNU General // 00019 // Public License as published by the Free Software Foundation; either // 00020 // version 2 of the License, or (at your option) any later version. // 00021 // // 00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope // 00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the // 00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // 00025 // PURPOSE. See the GNU General Public License for more details. // 00026 // // 00027 // You should have received a copy of the GNU General Public License // 00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write // 00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, // 00030 // Boston, MA 02111-1307 USA. // 00031 // //////////////////////////////////////////////////////////////////// // 00032 // 00033 // Primary maintainer for this file: Zack Gossman <gossman@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/BeoSub/test-ColorTracker.C $ 00035 // $Id: test-ColorTracker.C 14376 2011-01-11 02:44:34Z pez $ 00036 // 00037 00038 #ifndef TESTCOLORTRACKER_H_DEFINED 00039 #define TESTCOLORTRACKER_H_DEFINED 00040 00041 #include "BeoSub/ColorTracker.H" 00042 00043 //CAMERA STUFF 00044 #include "Image/Image.H" 00045 #include "Image/Pixels.H" 00046 00047 #include "Component/ModelManager.H" 00048 #include "Devices/FrameGrabberFactory.H" 00049 #include "Util/Timer.H" 00050 #include "Util/Types.H" 00051 #include "Util/log.H" 00052 00053 #include <cstdio> 00054 #include <cstdlib> 00055 #include <cstring> 00056 //END CAMERA STUFF 00057 00058 int main(int argc, char **argv) 00059 { 00060 float x = 0.0; 00061 float y = 0.0; 00062 float mass = 0; 00063 00064 //Parse the command line options 00065 char *infilename = NULL; //Name of the input image 00066 char *colorArg = NULL; //Color for tracking 00067 00068 if(argc < 3){ 00069 fprintf(stderr,"\n<USAGE> %s image color \n",argv[0]); 00070 fprintf(stderr,"\n image: An image to process. Must be in PGM format.\n"); 00071 fprintf(stderr," Type 'none' for camera input.\n"); 00072 fprintf(stderr," color: Color to track\n"); 00073 fprintf(stderr," Candidates: Blue, Yellow, Green, Orange, Red, Brown\n"); 00074 exit(1); 00075 } 00076 infilename = argv[1]; 00077 colorArg = argv[2]; 00078 00079 printf("READ: 1: %s 2: %s\n", infilename, colorArg); 00080 00081 // instantiate a model manager (for camera input): 00082 ModelManager camManager("ColorTracker Tester"); 00083 // Instantiate our various ModelComponents: 00084 nub::soft_ref<FrameIstream> 00085 gb(makeIEEE1394grabber(camManager, "colorcam", "cocam")); 00086 00087 if(!strcmp(infilename, "none")){ 00088 //GRAB image from camera to be tested 00089 camManager.addSubComponent(gb); 00090 00091 //Load in config file for camera FIX: put in a check whether config file exists! 00092 //camManager.loadConfig("camconfig.pmap"); 00093 00094 // set the camera number (in IEEE1394 lingo, this is the 00095 // "subchannel" number): 00096 // gb->setModelParamVal("FrameGrabberSubChan", 0); 00097 } 00098 camManager.start(); 00099 00100 // instantiate a model manager for the color tracker module: 00101 ModelManager manager("ColorTracker Tester"); 00102 00103 // Instantiate our various ModelComponents: 00104 nub::soft_ref<ColorTracker> test(new ColorTracker(manager)); 00105 manager.addSubComponent(test); 00106 00107 manager.start(); 00108 00109 Image< PixRGB<byte> > Img; 00110 00111 00112 if(!strcmp(infilename, "none")){ 00113 } 00114 else{ 00115 //TO TEST FROM FILE 00116 Img = Raster::ReadRGB(infilename); 00117 } 00118 00119 while(1){ 00120 //Get image to be matched 00121 //TO TEST FROM CAMERA 00122 if(!strcmp(infilename, "none")){ 00123 Img = gb->readRGB(); 00124 } 00125 00126 //run the matching code 00127 test->setupTracker(colorArg, Img, true); 00128 test->runTracker(25.0, x, y, mass); 00129 //printf("x:%f, y:%f, mass:%f\n",x,y, mass); 00130 } 00131 return 0; 00132 } 00133 00134 #endif 00135 // ###################################################################### 00136 /* So things look consistent in everyone's emacs... */ 00137 /* Local Variables: */ 00138 /* indent-tabs-mode: nil */ 00139 /* End: */