CRForest.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #ifndef CRForest_H
00004 #define CRForest_H
00005 
00006 #include "CRTree.h"
00007 #include <stdio.h>
00008 #include <vector>
00009 
00010 class CRForest {
00011   public:
00012     // Constructor
00013     CRForest(int trees = 0) {
00014       vTrees.resize(trees);
00015     }
00016 
00017     // Destructor
00018     ~CRForest() {
00019       for(std::vector<CRTree*>::iterator it = vTrees.begin(); it != vTrees.end(); ++it)
00020           delete *it; // delete pointers
00021       vTrees.clear(); // specialized routine for clearing trees
00022     }
00023 
00024     // Set/Get functions
00025     int getSize() const {return vTrees.size();} // get size of trees
00026     int getDepth() const {return vTrees[0]->getDepth();}
00027     int getPatchWidth(){ return vTrees[0]->getPatchWidth(); }
00028     int getPatchHeight(){ return vTrees[0]->getPatchHeight(); }
00029     int getNoChans(){ return vTrees[0]->getNoChannels(); }
00030 
00031     std::vector< const LeafNode* > regressionIntegral( const std::vector< cv::Mat >& patch, const cv::Mat& nonZeros, const cv::Rect& roi ) const;
00032 
00033         bool loadForest(const char* filename);
00034 
00035     // Trees
00036     std::vector<CRTree*> vTrees;
00037 
00038 
00039 };
00040 
00041 // Regression
00042 inline std::vector<const LeafNode*> CRForest::regressionIntegral( const std::vector< cv::Mat >& patch, const cv::Mat& nonZeros, const cv::Rect& roi ) const {
00043 
00044         std::vector<const LeafNode*> res;
00045         for(int i=0; i<(int)vTrees.size(); ++i)
00046                 res.push_back( vTrees[i]->regressionIntegral(patch,nonZeros,roi) );
00047         return res;
00048 }
00049 
00050 
00051 inline bool CRForest::loadForest(const char* filename) {
00052 
00053         char buffer[200];
00054         bool success = true;
00055         for(unsigned int i=0; i<vTrees.size(); ++i) {
00056                 sprintf(buffer,"%s%03d.bin",filename,i);
00057                 vTrees[i] = new CRTree();
00058                 success &= vTrees[i]->loadTree(buffer);
00059         }
00060         return success;
00061 }
00062 
00063 
00064 #endif


head_pose_estimation
Author(s): Daniel Lazewatsky
autogenerated on Mon Oct 6 2014 00:23:14