00001 /*!@file AppDevices/test-visca.C test the visca controller */ 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: Lior Elazary <elazary@usc.edu> 00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/AppDevices/test-visca.C $ 00035 // $Id: test-visca.C 13712 2010-07-28 21:00:40Z itti $ 00036 // 00037 00038 #include "Component/ModelManager.H" 00039 #include "Devices/Visca.H" 00040 #include "Util/log.H" 00041 00042 #include <stdio.h> 00043 00044 const char* USAGE = "-- <cmd> <optional data>\nwhere cmd is one of the following\n" 00045 "Cmd=resetPanTilt Reset pan/tilt\n" 00046 "Cmd=zoom data=x Zoom by <x> from 0 (wide), 1023 (tele)} \n" 00047 "Cmd=focus data=x focus by <x> from 4096 (infinity), 40959 (close)} \n" 00048 "Cmd=autoFocus data=0/1 Autofocus 1 manual 0\n" 00049 "Cmd=panTilt data=x y move pan to x and tilt to y\n" 00050 "Cmd=track Set the target tracking\n" 00051 "Cmd=getPanTilt getPanTilt pos\n"; 00052 00053 int main(int argc, const char **argv) 00054 { 00055 // Instantiate a ModelManager: 00056 ModelManager manager("Test Model for Visca Class"); 00057 00058 // Instantiate our various ModelComponents: 00059 nub::soft_ref<Visca> visca(new Visca(manager)); 00060 manager.addSubComponent(visca); 00061 00062 // Parse command-line: 00063 if (manager.parseCommandLine(argc, argv, 00064 USAGE, 1, 3) == false) return(1); 00065 00066 // Let's get some of the option values, to configure our window: 00067 std::string cmd = manager.getExtraArg(0).c_str(); 00068 //int serpos = atoi(manager.getExtraArg(1).c_str()); 00069 00070 00071 // let's get all our ModelComponent instances started: 00072 manager.start(); 00073 00074 if (cmd == "resetPanTilt") visca->resetPanTilt(); 00075 else if (cmd == "zoom") 00076 visca->zoom(atoi(manager.getExtraArg(1).c_str())); 00077 else if (cmd == "focus") 00078 visca->setFocus(atoi(manager.getExtraArg(1).c_str())); 00079 else if (cmd == "autoFocus") 00080 visca->setAutoFocus(atoi(manager.getExtraArg(1).c_str())); 00081 else if (cmd == "panTilt") 00082 visca->movePanTilt(manager.getExtraArgAs<int>(1), atoi(manager.getExtraArg(2).c_str())); 00083 else if (cmd == "track") 00084 visca->setTargetTracking(); 00085 else if (cmd == "getPanTilt") 00086 { 00087 short int pan =0, tilt =0; 00088 visca->getPanTilt(pan,tilt); 00089 LINFO("Pan %i Tilt %i", pan, tilt); 00090 } 00091 else 00092 LINFO("%s", USAGE); 00093 00094 // stop all our ModelComponents 00095 manager.stop(); 00096 00097 // all done! 00098 return 0; 00099 } 00100 00101 // ###################################################################### 00102 /* So things look consistent in everyone's emacs... */ 00103 /* Local Variables: */ 00104 /* indent-tabs-mode: nil */ 00105 /* End: */