|
From: Herton R. K. <he...@us...> - 2005-07-03 00:31:53
|
Update of /cvsroot/kimageprocess/kimageprocess/src/plugins/snns In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17042/snns Modified Files: snns.cpp snns.h Log Message: - Adapted fann plugin to the new plugin structure. Also added more variables to plugin class that handle more parameters of the fann network. - Misc cosmetics and cleanups at snns and fann plugins. Index: snns.cpp =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/snns/snns.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- snns.cpp 2 Jul 2005 23:42:52 -0000 1.11 +++ snns.cpp 3 Jul 2005 00:31:40 -0000 1.12 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2005 by * + * Copyright (C) 2004-2005 by * * Gustavo Pichorim Boiko <gus...@kd...> * * Herton Ronaldo Krzesinski <he...@my...> * * * @@ -42,7 +42,6 @@ m_tempFile = 0; } - KTSNNSPlugin::~KTSNNSPlugin() { } @@ -50,23 +49,22 @@ void KTSNNSPlugin::doTraining(const QValueList<dataEntry>& data, int inputs, int outputs) { KURL dest = KFileDialog::getSaveURL(QString::null,i18n("*.pat|Pattern files"),0,i18n("Save pattern")); - + if (!dest.isEmpty()) { - m_sampleImage = dest; m_tempFile = new KTempFile(); m_tempFile->setAutoDelete(false); if (m_tempFile->file()->isOpen()) - { + { m_stream.setDevice(m_tempFile->file()); - + m_stream << "SNNS pattern definition file V3.2" << endl; m_stream << "generated at " << QDateTime::currentDateTime().toString() << endl << endl << endl; m_stream << "No. of patterns : " << data.count() << endl; m_stream << "No. of input units : " << inputs << endl; m_stream << "No. of output units : " << outputs << endl << endl; - + QStringList names = KTImageManager::self()->activeFeatureNames(); QString features; for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it ) @@ -74,25 +72,25 @@ features += (*it) + " "; } m_stream << "#" << features << endl << endl; - + QValueList<dataEntry>::ConstIterator end = data.constEnd(); for (QValueList<dataEntry>::ConstIterator it = data.constBegin(); it != end; ++it) { QString line = ""; - + for ( int i=0; i < inputs; ++i ) line.sprintf("%s %.5f", line.ascii(), (*it).inputs[i]); - + m_stream << line.stripWhiteSpace() << endl; - + QString temp=""; for (int j = 1; j <= outputs; j++) if (j == (*it).sampleClass) temp += "1 "; else temp += "0 "; - + m_stream << temp.stripWhiteSpace() << endl << endl; } @@ -112,7 +110,6 @@ if (!dest.isEmpty()) { - m_sampleImage = dest; m_tempFile = new KTempFile(); m_tempFile->setAutoDelete(false); @@ -176,7 +173,10 @@ } void KTSNNSPlugin::setupPlugin() -{ -//connect signals/slots here +{ + //connect signals/slots here } + #include "snns.moc" + +// vim:et Index: snns.h =================================================================== RCS file: /cvsroot/kimageprocess/kimageprocess/src/plugins/snns/snns.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- snns.h 29 Jun 2005 02:41:43 -0000 1.9 +++ snns.h 3 Jul 2005 00:31:40 -0000 1.10 @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2004-2005 by * + * Copyright (C) 2004-2005 by * * Gustavo Pichorim Boiko <gus...@kd...> * * Herton Ronaldo Krzesinski <he...@my...> * * * @@ -23,18 +23,14 @@ #include <ktclassifbackend.h> +#include <ktempfile.h> + #include <qvaluelist.h> -#include <qvaluevector.h> #include <qstring.h> -#include <kurl.h> - -class KAction; -class KTImage; -class KTempFile; - /** A SNNS backend plugin + @author Gustavo Pichorim Boiko */ class KTSNNSPlugin : public KTClassifBackend @@ -51,17 +47,11 @@ void doTraining(const QValueList<dataEntry>& data, int inputs, int outputs); void doClassify(const QValueList<dataEntry>& data, int inputs, int outputs); - QString classifierName() { return "snns"; } -private: - KAction *m_generateTrainingPattern; - KAction *m_generateTesingPattern; - - KURL m_sampleImage; - KURL m_testingImage; + QString classifierName() { return "snns"; } +private: KTempFile *m_tempFile; QTextStream m_stream; - }; #endif |