intmain(int argc, char** argv){ Mat testImage = imread("dog.jpg"); if (testImage.empty()) { printf("could not load image...\n"); return-1; } // create googlenet with caffemodel text and bin Net net = dnn::readNetFromCaffe(modelTxt, modelBin); if (net.empty()) { std::cerr labels = readClasslabels(); //GoogLeNet accepts only 224x224 RGB-images Mat inputBlob = blobFromImage(testImage, 1, Size(224, 224), Scalar(104, 117, 123));//mean: Scalar(104, 117, 123) // 支持1000个图像分类检测 Mat prob; // 循环10+ for (int i = 0; i readClasslabels() { std::vector classNames; std::ifstream fp(labelFile); if (!fp.is_open()) { std::cerr
测试结果:
终端输出为:
1 2 3
Attempting to upgrade input file specified using deprecated V1LayerParameter: bvlc_googlenet.caffemodel Successfully upgraded file specified using deprecated V1LayerParameter current image classification : malemute, Alaskan malamute, possible : 0.42