PCamera.H

Go to the documentation of this file.
00001 /*!@file SceneUnderstanding/PCamera.H  */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00005 // by the 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/plugins/SceneUnderstanding/PCamera.H $
00035 // $Id: PCamera.H 13765 2010-08-06 18:56:17Z lior $
00036 //
00037 
00038 #ifndef PCamera_H_DEFINED
00039 #define PCamera_H_DEFINED
00040 
00041 //#include "Image/OpenCVUtil.H"  // must be first to avoid conflicting defs of int64, uint64
00042 
00043 #include "Image/Image.H"
00044 #include "Image/ImageSet.H"
00045 #include "Image/Pixels.H"
00046 #include "Image/Layout.H"
00047 #include "Image/Point3D.H"
00048 #include "Image/VisualTracker.H"
00049 #include "plugins/SceneUnderstanding/Camera.H"
00050 #include "plugins/SceneUnderstanding/Ganglion.H"
00051 #include "Simulation/SimEvents.H"
00052 #include "Simulation/SimModule.H"
00053 #include "Media/MediaSimEvents.H"
00054 #include "Component/ModelOptionDef.H"
00055 #include "Component/OptionManager.H" // for REQUEST_OPTIONALIAS_NEURO()
00056 #include "Component/ModelParam.H"
00057 #include "Devices/Visca.H"
00058 #include "GUI/ViewPort3D.H"
00059 
00060 #include <vector>
00061 #include <string>
00062 
00063 class PCamera : public SimModule
00064 {
00065 public:
00066 
00067   struct Square
00068   {
00069     Point2D<int> p[4];
00070   };
00071 
00072   PCamera(OptionManager& mgr, const std::string& descrName = "PCamera",
00073       const std::string& tagName = "PCamera");
00074 
00075   //! Destructor
00076   ~PCamera();
00077 
00078   void evolve();
00079 
00080   Layout<PixRGB<byte> > getDebugImage();
00081 
00082   void calibrate(std::vector<CvPoint2D32f>& corners);
00083 
00084   void displayExtrinsic(std::vector<CvPoint2D32f>& corners);
00085 
00086   void projectPoints(std::vector<Point3D<float> >& points);
00087 
00088   void projectGrid();
00089 
00090   void findSquares(const Image<PixRGB<byte> >& in, CvMemStorage* storage,
00091       const int minarea, const int maxarea, const double mincos);
00092 
00093   void getTransMat();
00094 
00095 
00096 protected:
00097 
00098   //! Callback for when a new input frame is available
00099   SIMCALLBACK_DECLARE(PCamera, SimEventInputFrame);
00100 
00101   //! Callback for every time we should save our outputs
00102   SIMCALLBACK_DECLARE(PCamera, SimEventSaveOutput);
00103 
00104   //! Callback for every time we have a user event
00105   SIMCALLBACK_DECLARE(PCamera, SimEventUserInput);
00106 
00107   void onSimEventPTZToLoc(SimEventQueue& q,
00108       rutz::shared_ptr<SimEventUserInput>& e);
00109 
00110   //! Should we show our debug info
00111   OModelParam<bool> itsShowDebug;
00112   nub::soft_ref<Visca> itsCameraCtrl;   //! The controller of the camera
00113 
00114 private:
00115   CvMemStorage* itsStorage;
00116   Image<PixRGB<byte> > itsCurrentImg;
00117   Image<PixRGB<byte> > itsRenderImg;
00118   ImageSet<float> itsPCameraCellsInput; //The input to the cells
00119   Image<byte> itsDebugImg;
00120   std::vector<Square> itsSquares;
00121         CvMat* itsIntrinsicMatrix;
00122         CvMat* itsDistortionCoeffs;
00123   CvMat* itsCameraRotation;
00124   CvMat* itsCameraTranslation;
00125   std::vector<CvPoint2D32f> itsCorners;
00126   std::string itsCurrentObjName;
00127   ViewPort3D* itsVP;
00128 
00129 
00130   Point2D<int> itsCurrentTargetLoc;
00131   bool itsZoomOut;
00132 
00133 
00134   bool itsIntrinsicInit;
00135   bool itsSaveCorners;
00136   bool itsDrawGrid;
00137   bool itsChangeRot;
00138 
00139 };
00140 
00141 // ######################################################################
00142 /* So things look consistent in everyone's emacs... */
00143 /* Local Variables: */
00144 /* indent-tabs-mode: nil */
00145 /* End: */
00146 
00147 #endif //
Generated on Sun May 8 08:05:31 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3