test_HEM.cpp

00001 
00008 #include <iostream>
00009 #include <iomanip>
00010 #include <string>
00011 #include <iterator>
00012 #include<fstream>
00013 #include<math.h>
00014 #include <ctime>
00015 
00016 #include "opencv/cv.h"
00017 #include "opencv/cxcore.h"
00018 #include "opencv/highgui.h"
00019 
00020 #include "options.h"
00021 #include "utils/libutils.h"
00022 #include "stats/libstats.h"
00023 #include "video/libvideo.h"
00024 #include "dytex/libdytex.h"
00025 #include "platInd/platInd.hpp"
00026 #include "bufferer/Bufferer.hpp"
00027 
00028 using namespace cv;
00029 using namespace std;
00030 
00036 string getTime()
00037 {
00038         std::time_t rawtime;
00039     std::tm* timeinfo;
00040     char buffer [80];
00041 
00042     std::time(&rawtime);
00043     timeinfo = std::localtime(&rawtime);
00044 
00045     std::strftime(buffer,80,"%Y-%m-%d-%H-%M-%S",timeinfo);
00046     std::puts(buffer);
00047 
00048         string tmpstr(buffer);
00049 
00050         return tmpstr;
00051 }
00052 
00053 
00054 int main(int argc, char** argv)
00055 {
00056         cout<<"Experiment Started: "<<getTime()<<endl;
00057 
00058         
00059         string fpath="../../testdata/HEM/47fa110.dtm";
00060 
00061         //load existing dtm     
00062         DytexMix dtm;
00063         Bufferer buf(fpath,fstream::in | fstream::binary);
00064         buf.read(dtm);  
00065         buf.close();
00066 
00067         
00068 
00069         //setting up HEM to reduce mixture to only 4 components
00070         DytexRegOptions ropt(CovMatrix::COV_REG_MIN,0.01,CovMatrix::COV_REG_MIN,0.01,CovMatrix::COV_REG_MIN,0.01,CovMatrix::COV_REG_ADD,0.999);
00071         HEMOptions hopt(4,ropt,0.0001,DytexOptions::NONZERO_YMEAN,HEMOptions::COMPACT);
00072 
00073         //split schedule of 1,2,4
00074         for(int i=1;i<=4;i=i*2)
00075         hopt.splitOpt.sched.push_back(i);
00076 
00077 
00078         //run The HEM 
00079         DytexMix emout=dtm.reduceWithSplitting(hopt);
00080         
00081                 
00082         for(int i=0;i<emout.alpha.size();i++)
00083                 cout<<"Alpha "<<i+1<<" is "<<std::fixed<<std::setprecision(14)<<emout.alpha[i]<<endl;
00084         
00085         
00086         cout<<"Experiment Finish: "<<getTime()<<endl;
00087 
00088 
00089 }

Generated on 18 Dec 2014 for libdt-OpenCV by  doxygen 1.6.1