Ask Your Question

harman's profile - activity

2017-08-25 05:08:43 -0500 asked a question Accessing the data of a multidimensional blob from dnn module

I'm using opencv's dnn module to interpret the output of a trained model.

The details of the blob are as follows:

cv::Mat output;
net.forward(output, "output_blob_name");

Now, I do the following:

std::cout << output.dims << "\n";

// output is 4

for (size_t i = 0; i < output.dims;++i) {  
    std::cout << output.size[i] << ", "; 

// output is: 1, 23, 23, 9

How do I access the data from this blob ?

2017-05-16 16:39:16 -0500 asked a question Unable to load caffe framework models in opencv

I'm following this tutorial, but I'm unable to successfully run the model. I have built opencv commit id:


along with opencv_modules commit id;


I was successfully able to build opencv, but when I run the tutorial code using :

$ g++ googlenet.cpp -o lenet `pkg-config --libs --cflags opencv`

I get the following error:

googlenet.cpp: In function ‘int main(int, char**)’:
googlenet.cpp:118:38: error: ‘blobFromImage’ was not declared in this scope
     Mat inputBlob = blobFromImage(img);   //Convert Mat to batch of images
googlenet.cpp:122:35: error: no matching function for call to ‘cv::dnn::Net::setBlob(const char [6], cv::Mat&)’
     net.setBlob(".data", inputBlob);        //set the network input
googlenet.cpp:122:35: note: candidate is:
In file included from /usr/local/include/opencv2/dnn.hpp:62:0,
                 from googlenet.cpp:41:
/usr/local/include/opencv2/dnn/dnn.hpp:248:22: note: void cv::dnn::Net::setBlob(cv::String, const cv::dnn::Blob&)
         CV_WRAP void setBlob(String outputName, const Blob &blob);
/usr/local/include/opencv2/dnn/dnn.hpp:248:22: note:   no known conversion for argument 2 from ‘cv::Mat’ to ‘const cv::dnn::Blob&’
googlenet.cpp:130:34: error: conversion from ‘cv::dnn::Blob’ to non-scalar type ‘cv::Mat’ requested
     Mat prob = net.getBlob("prob");   //gather output of "prob" layer

Details of my setup are:

Linux harman 3.19.0-78-generic #86~14.04.1-Ubuntu SMP Tue Dec 6 17:58:35 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

How do I resolve this error ?