You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code shows an example of how to use CURFIL as C++ library.
The example assumes that you already trained a random forest with three trees which are located in the current folder.
#include<iostream>
#include<vector>
#include<curfil/random_forest_image.h>
#include<curfil/predict.h>intmain(void) {
std::vector<std::string> treeFiles;
treeFiles.push_back("tree0.json.gz");
treeFiles.push_back("tree1.json.gz");
treeFiles.push_back("tree2.json.gz");
// load a random forest with three decision trees
curfil::RandomForestImage forest(treeFiles);
// load a RGB-D image from disk for prediction
curfil::RGBDImage image("01234_colors.png", "01234_depth.png");
// execute the actual prediction
curfil::LabelImage prediction = forest.predict(image);
// store the prediction result
prediction.save("prediction.png");
// load the ground truth labeling
curfil::LabelImage groundTruth("01234_ground_truth.png");
// calculate pixel accuracy and the confusion matrix
curfil::ConfusionMatrix confusionMatrix;
bool includeVoid = false;
double accuracy = curfil::calculatePixelAccuracy(prediction, groundTruth, includeVoid, &confusionMatrix);
std::cout << "pixel accuracy without void: " << accuracy << std::endl;
// print the confusion matrix
std::cout << confusionMatrix << std::endl;
return0;
}
Make sure to link your code to libcurfil (eg. -lcurfil).