Error while making a forward pass using net.forward()

asked 2017-05-26 06:48:08 -0500

anomaly_ gravatar image

updated 2017-05-26 07:13:12 -0500

I have the following lines of code :

Mat inputBlob = blobFromImage(img);   // img is the image file read by opencv
net.setBlob("l1_Convolution", inputBlob);   // "l1_convolution" is the name of my first layer
net.forward();

After executing the third line, I get the following error:

OpenCV Error: Assertion failed (input.dims == 4 && (input.type() == CV_32F || input.type() == CV_64F)) in allocate, file /home/anomaly_/opencv-base/opencv_contrib/modules/dnn/src/layers/convolution_layer.cpp, line 81

I found out the line where the code was breaking and I did the assertion in my main function:

CV_Assert(inputBlob.dims == 4 && (inputBlob.type() == CV_32F || inputBlob.type() == CV_64F));

which passed successfully. What can be the reason for the code failing? Is the input in convolution_layer.cpp different from inputBlob in main function? Or is there something wrong with the line net.setBlob("l1_Convolution", inputBlob); ?

Please help.

edit retag flag offensive close merge delete