TarzaNN
TarzaNN neural network simulator
C:/Users/albertlr/projects/TarzaNN/TarzaNN/InputVirtualFeaturePlane.h
Go to the documentation of this file.
00001 /****************************************************************************
00002  **
00003  ** Copyright C 2002-2012 Laboratory for Active and Attentive Vision (LAAV), Department of Computer Science and Engineering, York University, Toronto, ON, Canada.
00004  ** All rights reserved.
00005  **
00006  ** This file is part of the TarzaNN Neural Network Simulator.
00007  **
00008  ** This file may be distributed and/or modified under the terms of the
00009  ** GNU General Public License version 2 as published by the Free Software
00010  ** Foundation and appearing in the file LICENSE.GPL included in the
00011  ** packaging of this file.
00012  **
00013  ** See http://www.tarzann.org/gpl/ for GPL licensing information.
00014  **
00015  ** Contact info@tarzann.org if any conditions of this licensing are
00016  ** not clear to you.
00017  **
00018  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00019  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00020  **
00021  ****************************************************************************/
00022 
00023 #ifndef INPUTVIRTUALFEATUREPLANE_H_INCLUDED
00024 #define INPUTVIRTUALFEATUREPLANE_H_INCLUDED
00025 
00026 #include "nowarn.h"
00027 #include "common.h"
00028 
00029 #include "InputControllerAbstract.h"
00030 #include <QMutex>
00031 #include <QPainter>
00032 #include  <QImage>
00033 #include <QPixmap>
00034 
00035 class  InputVirtualFeaturePlane : public InputControllerAbstract {
00036         friend class FeaturePlaneFactory;
00037 protected:
00038     InputVirtualFeaturePlane( Network* net, int l, QString* n, int w, int h, const char * filename, NotifyStrategyAbstract* notify);
00039 public:
00040     ~ InputVirtualFeaturePlane();
00041     OutputImage* getHeadImage();
00042     QImage* getVirtualImage(bool showRect);
00043     bool moveHead(int deltaX, int deltaY, bool notify=true);
00044     int getVirtualWidth() { return virtualWidth;}
00045     int getVirtualHeight() { return virtualHeight;}
00046         
00047 private:
00048         InputVirtualFeaturePlane();
00049     QMutex localAccess;
00050         
00051     QImage *virtualImage;
00052     int virtualHeight, virtualWidth; // coordinates of the virtual image
00053     int h1,h2,w1,w2; // the coordinates of the window
00054         
00055 
00056 /**************************************************************************/
00057 void loadInputFeaturePlane(const char *filename) {
00058 
00059         virtualImage=new QImage(filename);
00060         virtualWidth = virtualImage->width();
00061         virtualHeight= virtualImage->height();
00062         
00063         // do some padding around !
00064         QPixmap *paddedVirtualImage = new QPixmap(virtualImage->width() + 2*this->width, virtualImage->height() + 2*this->height);
00065         QPainter *padPainter = new QPainter(paddedVirtualImage);
00066         padPainter->drawPixmap(this->width,this->height,QPixmap(*virtualImage));
00067         delete virtualImage;
00068         virtualImage = new QImage();
00069         (*virtualImage) = paddedVirtualImage->convertToImage();
00070         virtualImage->detach();
00071         delete padPainter;
00072         delete paddedVirtualImage;
00073         virtualWidth += 2*this->width;
00074         virtualHeight += 2*this->height;
00075                 
00076         if (virtualImage->isNull()) {
00077             printf("Could not find input image\n");
00078             delete virtualImage;
00079             virtualImage=NULL;
00080             virtualWidth = 0;
00081             virtualHeight = 0;
00082             this->outputs = 0;
00083         }
00084         else
00085             this->outputs=virtualImage->depth()/8 - 1;
00086                 
00087         this->setName(new QString("IFP"));
00088         printf("Input Virtual Feature Plane depthis %d\n",this->outputs);
00089     }
00090 };
00091 
00092 #endif // INPUTVIRTUALFEATUREPLANE_H_INCLUDED
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines