本文整理汇总了C++中GestureRecognitionPipeline::getMaximumLikelihood方法的典型用法代码示例。如果您正苦于以下问题:C++ GestureRecognitionPipeline::getMaximumLikelihood方法的具体用法?C++ GestureRecognitionPipeline::getMaximumLikelihood怎么用?C++ GestureRecognitionPipeline::getMaximumLikelihood使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GestureRecognitionPipeline
的用法示例。
在下文中一共展示了GestureRecognitionPipeline::getMaximumLikelihood方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: main
int main (int argc, const char * argv[])
{
GestureRecognitionPipeline pipeline;
ANBC anbc;
ClassificationData trainingData;
trainingData.loadDatasetFromFile("training-data.txt")
pipeline.setClassifier(anbc);
pipeline.train(trainingData);
VectorDouble inputVector(SAMPLE_DIMENSION) = getDataFromSensor();
pipeline.predict(inputVector);
UINT predictedClassLabel = pipeline.getPredictedClassLabel();
double maxLikelihood = pipeline.getMaximumLikelihood();
printf("predictedClassLabel : %d , MaximumLikelihood : %f \n", predictedClassLabel, maxLikelihood);
return EXIT_SUCCESS;
}
开发者ID:AravinthPanch,项目名称:gesture-recognition-for-human-robot-interaction,代码行数:20,代码来源:grt-pipeline.cpp
示例3: metrics_subset_data
//.........这里部分代码省略.........
//null rejection prediction
double accuracy = 0;
for(UINT i=0; i<nullGestureData.getNumSamples(); i++){
vector< double > inputVector = nullGestureData[i].getSample();
if( !pipeline.predict( inputVector )){
std::cout << "Failed to perform prediction for test sampel: " << i <<"\n";
}
UINT predictedClassLabel = pipeline.getPredictedClassLabel();
if(predictedClassLabel == 0 ) accuracy++;
}
opRecall << accuracy/double(nullGestureData.getNumSamples()) << ",";
// other classes prediction
for(int cl = 0; cl < testRes.recall.size(); cl++ ){
opRecall << testRes.recall[cl];
if(cl < testRes.recall.size() - 1){
opRecall << ",";
}
}
opRecall<< endl;
// Calculate instance prediction, precision, recall, fmeasure and confusion matrix for nullRejection 2.0
if(AreDoubleSame(nullRejectionCoeff, 2.0))
{
//instance prediction
for(UINT i=0; i<testData.getNumSamples(); i++){
UINT actualClassLabel = testData[i].getClassLabel();
vector< double > inputVector = testData[i].getSample();
if( !pipeline.predict( inputVector )){
std::cout << "Failed to perform prediction for test sampel: " << i <<"\n";
}
UINT predictedClassLabel = pipeline.getPredictedClassLabel();
double maximumLikelihood = pipeline.getMaximumLikelihood();
opInstanceRes << actualClassLabel << "," << predictedClassLabel << "," << maximumLikelihood << ","
<< inputVector[0] << "," << inputVector[1] << "," << inputVector[2] << "," << inputVector[3] << "," << inputVector[4] << "," << inputVector[5] << "\n";
}
//precision, recall, fmeasure
for(int cl = 0; cl < testRes.precision.size(); cl++ ){
opMetrics << testRes.precision[cl];
if(cl < testRes.precision.size() - 1){
opMetrics << ",";
}
}
opMetrics<< endl;
for(int cl = 0; cl < testRes.recall.size(); cl++ ){
opMetrics << testRes.recall[cl];
if(cl < testRes.recall.size() - 1){
opMetrics << ",";
}
}
opMetrics<< endl;
for(int cl = 0; cl < testRes.fMeasure.size(); cl++ ){
opMetrics << testRes.fMeasure[cl];
if(cl < testRes.fMeasure.size() - 1){
opMetrics << ",";
}
}
opMetrics<< endl;
//confusion matrix
MatrixDouble matrix = testRes.confusionMatrix;
for(UINT i=0; i<matrix.getNumRows(); i++){
for(UINT j=0; j<matrix.getNumCols(); j++){
opConfusion << matrix[i][j];
if(j < matrix.getNumCols() - 1){
opConfusion << ",";
}
}
opConfusion << endl;
}
opConfusion << endl;
}
}
cout << "Done\n";
}
示例4: prediction_axis_data
void prediction_axis_data(){
// Training and test data
ClassificationData trainingData;
ClassificationData testData;
string file_path = "../../../data/";
string class_name = "5";
if( !trainingData.loadDatasetFromFile(file_path + "train/grt/" + class_name + ".txt") ){
std::cout <<"Failed to load training data!\n";
}
if( !testData.loadDatasetFromFile(file_path + "test/grt/" + class_name + ".txt") ){
std::cout <<"Failed to load training data!\n";
}
// Pipeline setup
ANBC anbc;
anbc.setNullRejectionCoeff(1);
anbc.enableScaling(true);
anbc.enableNullRejection(true);
GestureRecognitionPipeline pipeline;
pipeline.setClassifier(anbc);
// Train the pipeline
if( !pipeline.train( trainingData ) ){
std::cout << "Failed to train classifier!\n";
}
// File stream
ofstream outputFileStream(class_name + ".csv");
// Evaluation
double accuracy = 0;
outputFileStream << "actualClass,predictedClass,maximumLikelihood,lZ,lY,lZ,rZ,rY,rZ \n";
for(UINT i=0; i<testData.getNumSamples(); i++){
UINT actualClassLabel = testData[i].getClassLabel();
vector< double > inputVector = testData[i].getSample();
if( !pipeline.predict( inputVector )){
std::cout << "Failed to perform prediction for test sampel: " << i <<"\n";
}
UINT predictedClassLabel = pipeline.getPredictedClassLabel();
double maximumLikelihood = pipeline.getMaximumLikelihood();
outputFileStream << actualClassLabel << "," << predictedClassLabel << "," << maximumLikelihood << ","
<< inputVector[0] << "," << inputVector[1] << "," << inputVector[2] << "," << inputVector[3] << "," << inputVector[4] << "," << inputVector[5] << "\n";
if( actualClassLabel == predictedClassLabel) accuracy++;
}
std::cout << "Test Accuracy testHandsUp : " << accuracy/double(testData.getNumSamples())*100.0 << " %\n";
}