本文整理汇总了C++中GestureRecognitionPipeline::getTrained方法的典型用法代码示例。如果您正苦于以下问题:C++ GestureRecognitionPipeline::getTrained方法的具体用法?C++ GestureRecognitionPipeline::getTrained怎么用?C++ GestureRecognitionPipeline::getTrained使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GestureRecognitionPipeline
的用法示例。
在下文中一共展示了GestureRecognitionPipeline::getTrained方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findGesture
std::string GRT_Recognizer::findGesture(VectorDouble input)
{
if( pipeline.getTrained()){
pipeline.predict(input);
UINT label = pipeline.getPredictedClassLabel();
if(pipeline.getMaximumLikelihood() < 0.6)
return "";
}
return "";
}
示例2: combineModels
bool combineModels( CommandLineParser &parser ){
infoLog << "Combining models..." << endl;
string directoryPath = "";
string modelFilename = "";
if( !parser.get("data-dir",directoryPath) ){
errorLog << "Failed to parse data-directory from command line! You can set the data-directory using the --data-dir option." << endl;
printUsage();
return false;
}
//Get the filename
if( !parser.get("model-filename",modelFilename) ){
errorLog << "Failed to parse filename from command line! You can set the model filename using the --model." << endl;
printUsage();
return false;
}
Vector< string > files;
infoLog << "- Parsing data directory: " << directoryPath << endl;
//Parse the directory to get all the csv files
if( !Util::parseDirectory( directoryPath, ".grt", files ) ){
errorLog << "Failed to parse data directory!" << endl;
return false;
}
RandomForests forest; //Used to validate the random forest type
GestureRecognitionPipeline *mainPipeline = NULL; // Points to the first valid pipeline that all the models will be merged to
Vector< GestureRecognitionPipeline* > pipelineBuffer; //Stores the pipeline for each file that is loaded
unsigned int inputVectorSize = 0; //Set to zero to mark we haven't loaded any models yet
const unsigned int numFiles = files.getSize();
bool mainPipelineSet = false;
bool combineModelsSuccessful = false;
pipelineBuffer.reserve( numFiles );
//Loop over the files, load them, and add valid random forest pipelines to the pipelineBuffer so they can be combined with the mainPipeline
for(unsigned int i=0; i<numFiles; i++){
infoLog << "- Loading model " << files[i] << ". File " << i+1 << " of " << numFiles << endl;
GestureRecognitionPipeline *pipeline = new GestureRecognitionPipeline;
if( pipeline->load( files[i] ) ){
infoLog << "- Pipeline loaded. Number of input dimensions: " << pipeline->getInputVectorDimensionsSize() << endl;
if( pipelineBuffer.size() == 0 ){
inputVectorSize = pipeline->getInputVectorDimensionsSize();
}
if( pipeline->getInputVectorDimensionsSize() != inputVectorSize ){
warningLog << "- Pipeline " << i+1 << " input vector size does not match the size of the first pipeline!" << endl;
}else{
Classifier *classifier = pipeline->getClassifier();
if( classifier ){
if( classifier->getClassifierType() == forest.getClassifierType() ){ //Validate the classifier is a random forest
if( !mainPipelineSet ){
mainPipelineSet = true;
mainPipeline = pipeline;
}else pipelineBuffer.push_back( pipeline );
}else{
warningLog << "- Pipeline " << i+1 << " does not contain a random forest classifer! Classifier type: " << classifier->getClassifierType() << endl;
}
}
}
}else{
warningLog << "- WARNING: Failed to load model from file: " << files[i] << endl;
}
}
if( mainPipelineSet ){
//Combine the random forest models with the main pipeline model
const unsigned int numPipelines = pipelineBuffer.getSize();
RandomForests *mainForest = mainPipeline->getClassifier< RandomForests >();
for(unsigned int i=0; i<numPipelines; i++){
infoLog << "- Combing model " << i+1 << " of " << numPipelines << " with main model..." << endl;
RandomForests *f = pipelineBuffer[i]->getClassifier< RandomForests >();
if( !mainForest->combineModels( *f ) ){
warningLog << "- WARNING: Failed to combine model " << i+1 << " with the main model!" << endl;
}
}
if( mainPipeline->getTrained() ){
infoLog << "- Saving combined pipeline to file..." << endl;
combineModelsSuccessful = mainPipeline->save( modelFilename );
}
}else{
errorLog << "Failed to combined models, no models were loaded!" << endl;
//.........这里部分代码省略.........