TarzaNN
TarzaNN neural network simulator
C:/Users/albertlr/projects/TarzaNN/TarzaNN/OutputImage.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 OUTPUTIMAGE_H_INCLUDED
00024 #define OUTPUTIMAGE_H_INCLUDED
00025 
00026 #include "Matrix.h"
00027 #include <QMutex>
00028 #include <QImage>
00029 #include <QDataStream> 
00030 #include <q3socketdevice.h> 
00031 
00033 class OutputImage:public Matrix{
00034 public:
00035         OutputImage(const OutputImage& image);
00036         OutputImage(int w, int h, int id);
00038         OutputImage( char* buf);
00039 
00040         ~OutputImage();
00041 
00042         int timeStamp;
00043         int depth;
00045         int fpID;
00047         void incUseCount();
00049         void release();
00051         inline bool isInUse(){
00052                 bool ret;
00053                 try {
00054                         useCountMutex.lock();
00055                         //qDebug() << "Checked useCount to " << useCount;
00056                         ret=(useCount!=0);
00057                         useCountMutex.unlock();
00058                 }
00059                 catch (int exc) {
00060                         ret=true;
00061                 }
00062                 return ret;
00063         }
00065         void serialize(char* buf);
00067         int getSendSize();
00068 
00069         /*Initializes from a QImage*/
00070         void fromQImage(QImage* image, bool scale, float min, float max, OutputImage** list=NULL, int outputs=0);
00071         /*Transform into a QImage*/
00072         QImage* toQImage(QImage* tmpImage, float max_activation, float* minRealPixelValue=NULL, float* maxRealPixelValue=NULL);
00073         QImage* toScaledQImage(QImage* tmpImage, float min, float max);
00075         OutputImage* toResizedImage(int newX, int newY);
00076 
00077 
00078 private:
00080         QMutex useCountMutex;
00082         int useCount;
00083         bool live;
00084 };
00085 
00086 #endif /*OUTPUTIMAGE_H_INCLUDED*/
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines