dnn forward Mat size and dimensions are wierd

asked 2018-05-09 09:59:45 -0600

Jonny gravatar image

I am running the OpenCV demo dnn code from here:
https://docs.opencv.org/trunk/d5/de7/...
However, when I do the forward pass:
Mat prob = net.forward();
prob has the following attributes:
prob.dims 2
prob.channels: 1
prob.rows: 1
prob.cols 1000
prob.depth: 5
prob.size[0]: 1
prob.size[1]: 1000
prob.size[2]: 213147712
prob.size[3]: 277

In most examples, to find he coordinates, it loops through prob.size[2], which in my case is 21347712!

Any ideas what's going on?

edit retag flag offensive close merge delete

Comments

In most examples. Please provide a reference to at least one of them. GoogLeNet is a classification network and it produces a vector with confidences where number of elements equals to number of classes.

dkurt gravatar imagedkurt ( 2018-05-09 10:45:40 -0600 )edit

What I'm really trying to get at is the coordinates of the detected objects. I could not find a good example of that in c++. In this example, the loop is through detector.size[2]: https://stackoverflow.com/questions/4...

Jonny gravatar imageJonny ( 2018-05-09 11:01:53 -0600 )edit

@Jonny, have you tried https://github.com/opencv/opencv/blob... ? And you need to use network trained for object detection problem.

dkurt gravatar imagedkurt ( 2018-05-09 11:30:09 -0600 )edit

Got it: wrong network model for object detection. Thanks for the pointer.

Jonny gravatar imageJonny ( 2018-05-09 14:55:33 -0600 )edit

@Jonny, if dims==2, only size[0] and size[1] are valid (or even properly allocated)

both 213147712 and 277 are bogus values.

imho, your classification example works perfect (googlenet indeed has class 1000 labels), and you only got confused by the wrong sizes.

if you wanted to do object detection with it, it's the wrong example, and the wrong network

berak gravatar imageberak ( 2018-05-10 01:49:39 -0600 )edit