Skip to content

Instantly share code, notes, and snippets.

@ivder
Created April 23, 2019 00:28
Show Gist options
  • Save ivder/d4d3fd017e6a267f5a257aec459cc80a to your computer and use it in GitHub Desktop.
Save ivder/d4d3fd017e6a267f5a257aec459cc80a to your computer and use it in GitHub Desktop.
Intel OpenVino Classification
#include "ClassificationWithIntel.h"
#include "IntelClassification.h"
using namespace IntelVINOLib;
class ClassificationWithIntelContext
{
public:
ClassificationWithIntelContext() {}
~ClassificationWithIntelContext() {}
IntelVINOClassification* Intel_VINO_Classification;
};
ClassificationWithIntel::ClassificationWithIntel(std::string modelPath) {
IntelModelPath = modelPath;
ctx = new ClassificationWithIntelContext();
ctx->Intel_VINO_Classification = new IntelVINOClassification(IntelModelPath);
}
ClassifyResultCNN ClassificationWithIntel::Classify(std::string imagePath) {
IntelImagePath = imagePath;
int predictionNum= ctx->Intel_VINO_Classification->IntelClassify(IntelImagePath);
std::string prediction;
if (predictionNum == 18) {
prediction = "patchdamaged";
}
else if (predictionNum == 20) {
prediction = "pothole";
}
else if (predictionNum == 23) {
prediction = "spalling";
}
else if (predictionNum == 24) {
prediction = "spallingcross";
}
else {
prediction = "nonDefect";
}
ofstream outfile;
outfile.open("C:\\algorithm_testing\\inference.txt", ios::out | ios::app);
outfile << to_string(predictionNum) << " " << prediction << endl;
outfile.close();
ClassifyResultCNN R;
R.className = prediction;
//R.predictRate = predictions.at(0).second * 100;
R.isDefect = R.className.compare(DEFECT_PATCHDAMAGED) == 0
|| R.className.compare(DEFECT_SPALLING) == 0 || R.className.compare(DEFECT_SPALLINGCROSS) == 0
|| R.className.compare(DEFECT_POTHOLE) == 0;
return R;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment