Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unknown Opencv Predict error (assertion Failed)

I am using Opencv and having problems with the predict stage of the process.

The Preprocessing and Prediction stage are as followed:

cap.read(edges);//take frame from edges
    flat_Img = edges.reshape(1,1);//converts image row by row to 1 by x res


    flat_Img.convertTo(arr_Img,CV_32F);//,1/255.0); //converts 1 by x imaeg to an array  
    imshow("arr_img",arr_Img);//show array values on screen

    }

        Mat Result;
        Mat CurrentImg = Mat::ones(arr_Img.rows,arr_Img.cols, CV_32FC1);
        Neural_Net->predict(CurrentImg,Result);
        cout << Result << endl;

However I keep getting the error here when the predict stage occurs:

OpenCV Error: Assertion failed ((type == CV_32F || type == CV_64F) && inputs.cols == layer_sizes[0]) in predict, file /home/pi/selfdrivingcar/opencv/opencv-3.1.0/modules/ml/src/ann_mlp.cpp, line 251
terminate called after throwing an instance of 'cv::Exception'
  what():  /home/pi/selfdrivingcar/opencv/opencv-3.1.0/modules/ml/src/ann_mlp.cpp:251: error: (-215) (type == CV_32F || type == CV_64F) && inputs.cols == layer_sizes[0] in function predict

any idea what could be causing it? I have trained the NN correctly etc but cant figure out why this wouldnt work!