CudaFramework.H

Go to the documentation of this file.
00001 /*!@file CUDA/CudaFramework.H A class for CUDA display framework  */
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:
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/CUDA/CudaFramework.H $
00035 // $Id: CudaFramework.H 12962 2010-03-06 02:13:53Z irock $
00036 //
00037 #ifndef CUDAFRAMEWORK_H_DEFINED
00038 #define CUDAFRAMEWORK_H_DEFINED
00039 
00040 #include <stdio.h>
00041 #include <stdlib.h>
00042 #include <string.h>
00043 #include <pthread.h>
00044 #include <errno.h>
00045 #include <GL/glew.h>
00046 #include <cuda_runtime.h>
00047 #include <cuda_gl_interop.h>
00048 #include "CUDA/CudaImage.H"
00049 #include "CUDA/CudaImageSet.H"
00050 #include "Image/Pixels.H"
00051 #include "Image/MathOps.H"
00052 #if defined(__APPLE__) || defined(MACOSX)
00053 #include <GLUT/glut.h>
00054 #else
00055 #include <GL/glut.h>
00056 #endif
00057 
00058 #include "CudaImageDisplay.h"
00059 #include <unistd.h>
00060 #include "CUDA/CudaShapeOps.H"
00061 #include "Raster/Raster.H"
00062 #include "Raster/PngWriter.H"
00063 #include "CUDA/CudaCutPaste.H"
00064 #include "Component/ModelManager.H"
00065 #include "CUDA/CudaSaliency.H"
00066 #include "Image/SimpleFont.H"
00067 #include "Image/DrawOps.H"
00068 #include "Raster/Raster.H"
00069 #include "Raster/GenericFrame.H"
00070 #include "Media/FrameSeries.H"
00071 #define MAX_SIZE 14
00072 
00073 class CudaFramework
00074 {
00075 
00076 public:
00077 
00078 
00079   //! Constructor
00080   CudaFramework();
00081 
00082 
00083   //! Destructor
00084   ~CudaFramework();
00085 
00086 
00087   //! Get Canvas Width
00088   int getCanvasW();
00089 
00090 
00091   //! Get Canvas Height
00092   int getCanvasH();
00093 
00094 
00095   //! Get the canvas
00096   CudaImage<PixRGB<float> >& getCanvas();
00097 
00098 
00099   //! Get point with index i
00100   Point2D<int> getPoint(int i);
00101 
00102 
00103   //! Get the Memory policy
00104   MemoryPolicy getMP();
00105 
00106 
00107   //! Get the device
00108   int getDev();
00109 
00110 
00111   //! Get the lock Attributes
00112   int getLockAtt();
00113 
00114 
00115   //! Get if canvas is modified
00116   bool getCanvasModified();
00117 
00118 
00119   //! Get image total width
00120   int getW();
00121 
00122 
00123   //! Get Image total height
00124   int getH();
00125 
00126 
00127   //! Sets the memory policy
00128   void setMP(MemoryPolicy mp);
00129 
00130 
00131   //! Sets the device
00132   void setDev(int dev);
00133 
00134 
00135   //! Sets the pthread mutex to destroy
00136   void setMutexDestroy();
00137 
00138 
00139   //! Sets the pthread mutex to unlock
00140   void setMutexUnlock();
00141 
00142 
00143   //! Sets the canvas modified to new state
00144   void setCanvasModified(bool new_state);
00145 
00146 
00147   //! Sets the Point with index i to coordinates in pt
00148   void setPoint(int i,Point2D<int> pt);
00149 
00150 
00151   //! Sets the total width as W
00152   void setW(int W);
00153 
00154 
00155   //! Sets the total height as H
00156   void setH(int H);
00157 
00158 
00159   //! Updates the canvas with index i and image stored in src
00160   void updateCanvas(int i, CudaImage<PixRGB<float> > &src);
00161 
00162 
00163   //! Starts the framework with width w , height h , cuda device dev and memory policy mp
00164   void startFramework(int w,int h,int dev,MemoryPolicy mp);
00165 
00166   //! Draws a rectangle on the canvas with centre point as input
00167   void drawRectangle_centrepoint(Point2D<int> centre_point, const PixRGB<float> color,const int w,const int h, const int rad);
00168 
00169   //! Draws a rectangle on the canvas with top left point as input
00170   void drawRectangle_topleftpoint(Point2D<int> topleft_point, const PixRGB<float> color,const int w,const int h, const int rad);
00171 
00172   //! Sets the text on the text patch which is in place pasted on the canvas
00173   void setText(const char* text,Point2D<int> text_coord,const PixRGB<float> color,const PixRGB<float> bgcolor,const SimpleFont& f,bool transparent_background);
00174 
00175   //! Initialises the text patch with width w and height h
00176   void initTextLayer(int w,int h);
00177 
00178 private:
00179 
00180   Point2D<int> point_list[MAX_SIZE];
00181   int dev1;
00182   MemoryPolicy mp1;
00183   int w,h;
00184   CudaImage<PixRGB<float> > canvas_image;
00185   pthread_mutex_t canvas_lock;
00186   bool canvasModified;
00187   int saliency_rectangle_size ;
00188   Image<PixRGB<float> > text_patch;
00189   CudaImage<PixRGB<float> > text_patch_cuda;
00190 };
00191 
00192 #endif
00193 
00194 // ######################################################################
00195 /* So things look consistent in everyone's emacs... */
00196 /* Local Variables: */
00197 /* indent-tabs-mode: nil */
00198 
00199 
Generated on Sun May 8 08:04:43 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3