Commit 55856bd9 authored by Vitaliy Lyudvichenko's avatar Vitaliy Lyudvichenko

Updating of googlenet sample

parent 4b99c937
...@@ -88,19 +88,12 @@ int main(int argc, char **argv) ...@@ -88,19 +88,12 @@ int main(int argc, char **argv)
String modelBin = "bvlc_googlenet.caffemodel"; String modelBin = "bvlc_googlenet.caffemodel";
String imageFile = (argc > 1) ? argv[1] : "space_shuttle.jpg"; String imageFile = (argc > 1) ? argv[1] : "space_shuttle.jpg";
//! [Create the importer of Caffe model] //! [Read and initialize network]
Ptr<dnn::Importer> importer; Net net = dnn::readNetFromCaffe(modelTxt, modelBin);
try //Try to import Caffe GoogleNet model //! [Read and initialize network]
{
importer = dnn::createCaffeImporter(modelTxt, modelBin);
}
catch (const cv::Exception &err) //Importer can throw errors, we will catch them
{
std::cerr << err.msg << std::endl;
}
//! [Create the importer of Caffe model]
if (!importer) //! [Check that net was read successfully]
if (net.empty())
{ {
std::cerr << "Can't load network by using the following files: " << std::endl; std::cerr << "Can't load network by using the following files: " << std::endl;
std::cerr << "prototxt: " << modelTxt << std::endl; std::cerr << "prototxt: " << modelTxt << std::endl;
...@@ -109,12 +102,7 @@ int main(int argc, char **argv) ...@@ -109,12 +102,7 @@ int main(int argc, char **argv)
std::cerr << "http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel" << std::endl; std::cerr << "http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel" << std::endl;
exit(-1); exit(-1);
} }
//! [Check that net was read successfully]
//! [Initialize network]
dnn::Net net;
importer->populateNet(net);
importer.release(); //We don't need importer anymore
//! [Initialize network]
//! [Prepare blob] //! [Prepare blob]
Mat img = imread(imageFile); Mat img = imread(imageFile);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment