Browse Source

*** empty log message ***

froehlich 14 năm trước cách đây
mục cha
commit
f699847f55
3 tập tin đã thay đổi với 250 bổ sung0 xóa
  1. 89 0
      progs/classtest.cpp
  2. 74 0
      progs/convertFeatures.cpp
  3. 87 0
      progs/convertFeatures2.cpp

+ 89 - 0
progs/classtest.cpp

@@ -0,0 +1,89 @@
+#include <iostream>
+#include <fstream>
+#include <core/vector/VectorT.h>
+#include <limits>
+
+using namespace std;
+using namespace NICE;
+
+template<class ElementType>
+class SparseVectorT : public VectorT<ElementType> {
+	size_t dsize;
+public:
+	SparseVectorT(const size_t size, const ElementType& element):VectorT<ElementType>(size,element){dsize = 5;}
+	virtual inline size_t size() const { return dsize; }
+};
+
+
+void printit(VectorT<double> &e)
+{
+	//cout << e.size() << endl;
+	size_t a = 0;
+	for(int i = 0; i < numeric_limits<int>::max(); i++)
+	{
+		a = e.size();
+	}
+}
+
+int main(int argc, char **argv)
+{
+	VectorT<double> k(2,2.0);
+	/*cout << "print1 vector:" << endl;
+	cout << e.size()<< endl;*/
+
+	//SparseVectorT<double> k(2,2.0);
+/*	cout << "print2 sparse:" << endl;
+	cout << k.size()<< endl;*/
+/*
+	cout << "print3 vectormethode:" << endl;
+	printit(e);
+
+	cout << "print4 sparsemethode:" << endl;*/
+	printit(k);
+	return 0;
+}
+
+/*
+
+class Elter
+{
+protected:
+	int t1;
+	int t2;
+
+public:
+	Elter():t1(1),t2(2){}
+	virtual void print(){cout << "t1: " << t1 << endl;}
+};
+
+class Kind:public Elter
+{
+public:
+	Kind(){t1 = 3; t2 = 4;}
+	virtual void print(){cout << "t2: " << t2 << endl;}
+};
+
+void printit(Elter &e)
+{
+	e.print();
+}
+
+int main(int argc, char **argv)
+{
+	Elter e;
+	cout << "print1 elter:" << endl;
+	e.print();
+
+	Kind k;
+	cout << "print2 kind:" << endl;
+	k.print();
+
+	cout << "print3 eltermethode:" << endl;
+	printit(e);
+
+
+	cout << "print3 kindmethode:" << endl;
+	printit(k);
+	return 0;
+}
+*/

+ 74 - 0
progs/convertFeatures.cpp

@@ -0,0 +1,74 @@
+/** 
+* @file testClassifier.cpp
+* @brief main program for classifier evaluation
+* @author Erik Rodner
+* @date 2007-10-12
+*/
+
+#include <objrec/nice_nonvis.h>
+
+#include <fstream>
+#include <iostream>
+
+#include <objrec/cbaselib/MultiDataset.h>
+#include <objrec/iclassifier/icgeneric/CSGeneric.h>
+#include <objrec/cbaselib/ClassificationResults.h>
+#include <objrec/iclassifier/codebook/MutualInformation.h>
+
+#include "objrec/classifier/classifierbase/FeaturePoolClassifier.h"
+#include <objrec/classifier/fpclassifier/randomforest/FPCRandomForestTransfer.h>
+#include <objrec/classifier/classifierinterfaces/VCFeaturePool.h>
+
+#include <objrec/baselib/Config.h>
+#include <objrec/baselib/Preprocess.h>
+#include <objrec/baselib/StringTools.h>
+
+#undef DEBUG
+
+using namespace OBJREC;
+
+using namespace NICE;
+using namespace std;
+
+int main (int argc, char **argv)
+{
+	std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
+
+	Config conf ( argc, argv );
+	string fn = conf.gS("main", "input", "train.vec");
+	int format = conf.gI("main", "format", 0 );
+	string outfn = conf.gS("main", "output", "out.vec");
+	
+	LabeledSetVector test;
+
+	test.read (fn, format );
+	cout << "fn: " << fn << endl;
+	
+	ofstream fout(outfn.c_str());
+	ofstream cn((outfn+".cn").c_str());
+	
+	fout << test.count() << endl;
+	cn << test.count() << endl;
+	fout << test.dimension();
+	cn << 1;
+
+	for( map< int, vector<NICE::Vector *> >::iterator iter = test.begin(); iter != test.end(); ++iter ) 
+	{
+		for(int j = 0; j < iter->second.size(); j++)
+		{
+			Vector vec = *(iter->second[j]);
+			cn << endl << iter->first;
+			fout << endl;
+			for(int i = 0; i < vec.size()-1; i++)
+			{
+				fout << vec[i] << " ";
+			}
+			fout << vec[vec.size()-1];
+		}
+	}
+	
+	fout.close();
+	cn.close();
+	
+    return 0;
+}

+ 87 - 0
progs/convertFeatures2.cpp

@@ -0,0 +1,87 @@
+/** 
+* @file testClassifier.cpp
+* @brief main program for classifier evaluation
+* @author Erik Rodner
+* @date 2007-10-12
+*/
+
+#include <objrec/nice_nonvis.h>
+
+#include <fstream>
+#include <iostream>
+
+#include <objrec/cbaselib/MultiDataset.h>
+#include <objrec/iclassifier/icgeneric/CSGeneric.h>
+#include <objrec/cbaselib/ClassificationResults.h>
+#include <objrec/iclassifier/codebook/MutualInformation.h>
+
+#include "objrec/classifier/classifierbase/FeaturePoolClassifier.h"
+#include <objrec/classifier/fpclassifier/randomforest/FPCRandomForestTransfer.h>
+#include <objrec/classifier/classifierinterfaces/VCFeaturePool.h>
+
+#include <objrec/baselib/Config.h>
+#include <objrec/baselib/Preprocess.h>
+#include <objrec/baselib/StringTools.h>
+
+#undef DEBUG
+
+using namespace OBJREC;
+
+using namespace NICE;
+using namespace std;
+
+int main (int argc, char **argv)
+{
+	std::set_terminate(__gnu_cxx::__verbose_terminate_handler);
+
+	Config conf ( argc, argv );
+	string fn = conf.gS("main", "input", "train.vec");
+	int format = conf.gI("main", "format", 0 );
+	string outfn = conf.gS("main", "output", "out.vec");
+	int dim = conf.gI("main", "dim", 0);
+	
+	ifstream fin(fn.c_str(), ifstream::in);
+
+	LabeledSetVector test;
+	vector<double> maxv(dim,numeric_limits<double>::min());
+	vector<double> minv(dim,numeric_limits<double>::max());
+	
+	while(fin.good())
+	{
+		Vector tmp(dim);
+		for(int i = 0; i < dim; i++)
+		{
+			fin >> tmp[i];
+			maxv[i] = std::max(maxv[i],tmp[i]);
+			minv[i] = std::min(minv[i],tmp[i]);
+		}
+		int label;
+		fin >> label;
+		label--;
+		if(label > 5)
+			label--;
+		test.add(label, tmp);
+	}
+	
+	for(int i = 0; i < dim; i++)
+	{
+		maxv[i] -= minv[i];
+	}
+	
+	for( map< int, vector<NICE::Vector *> >::iterator iter = test.begin(); iter != test.end(); ++iter ) 
+	{
+		for(int j = 0; j < iter->second.size(); j++)
+		{
+			for(int i = 0; i < iter->second[j]->size(); i++)
+			{
+				(*(iter->second[j]))[i] = ((*(iter->second[j]))[i] - minv[i]) / maxv[i];
+			}
+		}
+	}
+		
+	test.save(outfn);
+	fin.close();
+
+	
+    return 0;
+}