00001 /* -*- c++ -*- (for Emacs) 00002 * 00003 * linearrecognisertrainer.h 00004 * Digest 00005 * 00006 * Created by Aidan Lane on Mon Jul 11 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 LINEARRECOGNISERTRAINER_H 00026 #define LINEARRECOGNISERTRAINER_H 00027 00028 00029 #include "abstractrecognisertrainer.h" 00030 00031 #include "linearrecogniser.h" 00032 00033 #include <QHash> 00034 #include <QVector> 00035 00036 00037 class LinearRecogniserTrainer : public AbstractRecogniserTrainer { 00038 00039 typedef double WeightT; 00040 00041 public: 00042 LinearRecogniserTrainer( JavaVM* jvm, 00043 DigestDbModel* digestDbModel, 00044 QObject* parent = 0 ); 00045 00046 // Define the key and the title using LinearRecogniser, ensuring sync: 00047 DECLARE_CLASS_KEY( LinearRecogniser::classKey() ); 00048 DECLARE_CLASS_TITLE_NONTR( LinearRecogniser::classTitle() ); 00049 DECLARE_CLASS_DESCRIPTION_NONTR( LinearRecogniser::classDescription() ); 00050 00051 00052 protected: 00053 bool prepareForTraining(); 00054 bool examineSample( const DGestureRecord& sample, 00055 const QVector<FeatureResultT>& featureVec ); 00056 bool finalizeTraining(); 00057 bool writeModelFile( const QString& fileName ); 00058 00059 00060 private: 00061 /* Class -> Sample -> Feature result vector 00062 * 00063 * Datatype rational: 00064 * - QHash for class : class IDs are not sequential 00065 * - QList for sample : sequential of UNknown number for each class 00066 * - QVector for results : sequential and length known (==|featureKeys|) 00067 * 00068 * Note: It's better to use QVector vs. QList if the length is known in 00069 * advance and will remain static in length, where all the memory 00070 * will be allocated once (and immediately). 00071 */ 00072 QHash<int, QList< QVector<FeatureResultT> > > m_classSampleResults; 00073 int c_numFeatures; // cached value 00074 00075 QHash< int, QVector<WeightT> > m_classWeights; 00076 }; 00077 00078 00079 #endif // ! LINEARRECOGNISERTRAINER_H
1.5.2