javarecogniserwrapper.h

Go to the documentation of this file.
00001 /*  -*- c++ -*-  (for Emacs)
00002  *
00003  *  javarecogniserwrapper.h
00004  *  Digest
00005  * 
00006  *  Created by Aidan Lane on Fri Oct 28 2005.
00007  *  Copyright (c) 2005-2006 Optimisation and Constraint Solving Group,
00008  *  Monash University. All rights reserved.
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00023  */
00024 
00025 #ifndef JAVARECOGNISERWRAPPER_H
00026 #define JAVARECOGNISERWRAPPER_H
00027 
00028 
00029 #include "abstractrecogniser.h"
00030 
00031 
00032 class JavaRecogniserWrapper : public AbstractRecogniser {
00033 
00034 public:
00035   JavaRecogniserWrapper( const QString& javaClassName,
00036                          JavaVM* jvm,
00037                          DigestDbModel* digestDbModel,
00038                          QObject* parent = 0 );
00039 
00040   virtual ~JavaRecogniserWrapper();
00041 
00042   virtual QByteArray  key()         const;
00043   virtual QString     title()       const;
00044   virtual QString     description() const;
00045 
00046   QHash<QString, QVariant> defaultParams() const;
00047 
00048   const QString& javaClassName() const;
00049 
00050 
00051 protected:
00052   virtual bool initTraining( const QList<QByteArray>& featureKeys,
00053                              const QHash<QString, QVariant>& params );
00054   virtual bool examineSample( const FeatureVec& featureVec,
00055                               const QSet<int>& classes );
00056   virtual bool finaliseTraining();
00057 
00058   virtual bool writeModelFile( const QString& fileName );
00059   virtual bool readModelFile( const QString& fileName );
00060 
00061   virtual Stroke flatten( const StrokeList& strokes );
00062   virtual ClassProbabilities classify( const FeatureVec& featureVec );
00063 
00064   jmethodID tryGetMethodID( jclass cls, const char* name, const char* sig );
00065   QString jstringToQString( jstring jstr ) const;
00066 
00067 
00068 private:
00069   void cleanup();
00070 
00071 
00072   QString m_javaClassName;
00073 
00074   // The following is tied to the thread - do not use them outside of it
00075   // TODO: move what doesn't need to be global back into impl file
00076   // TODO: share MIDs!
00077   JNIEnv*    m_env;
00078 
00079   // Trainer class:
00080   jclass     m_recog_cls;
00081   jobject    m_recog_gref;
00082   jmethodID  m_recog_constructor_mid;
00083   jmethodID  m_recog_key_mid;
00084   jmethodID  m_recog_title_mid;
00085   jmethodID  m_recog_description_mid;
00086   jmethodID  m_recog_initTraining_mid;
00087   jmethodID  m_recog_examineSample_mid;
00088   jmethodID  m_recog_finaliseTraining_mid;
00089   jmethodID  m_recog_writeModelFile_mid;
00090   jmethodID  m_recog_readModelFile_mid;
00091   jmethodID  m_recog_flatten_mid;
00092   jmethodID  m_recog_classify_mid;
00093 
00094   // Vector class:
00095   jclass     m_vector_cls;
00096   jmethodID  m_vector_constructor_mid;
00097   jmethodID  m_vector_add_mid;
00098 
00099   // Double class:
00100   jclass     m_double_cls;
00101   jmethodID  m_double_constructor_mid;
00102 };
00103 
00104 
00105 #endif  // ! JAVARECOGNISERWRAPPER_H

Generated on Mon Jul 30 09:46:50 2007 for Digest by  doxygen 1.5.2