Ask Your Question

Revision history [back]

OpenCV(3.4.11) Error: Unspecified error (Number of input channels should be multiple of 3 but got 4

I mauising opencv 3.4.11 for android. I get this error when i used the forward of Net function:

        Mat imageBlob = Dnn.blobFromImage(frame, 0.00392, new Size(416,416),new Scalar(0, 0, 0),/*swapRB*/false, /*crop*/false);
        tinyV4.setInput(imageBlob);

        /* the result */
        java.util.List<Mat> result = new java.util.ArrayList<Mat>(2);
        List<String> outputLayers = new java.util.ArrayList<>();
        /* the outputs layers are 30 and 37*/
        outputLayers.add(0, "yolo_30");
        outputLayers.add(1, "yolo_37");
        /*we are looking for layers yolo30 and yolo37, and we want to save them into result */
        tinyV4.forward(result, outputLayers);

The full error: OpenCV(3.4.11) Error: Unspecified error (Number of input channels should be multiple of 3 but got 4) in virtual bool cv::dnn::ConvolutionLayerImpl::getMemoryShapes(const std::vector<std::vector<int> >&, int, std::vector<std::vector<int> >&, std::vector<std::vector<int> >&) const, file /build/3_4_pack-android/opencv/modules/dnn/src/layers/convolution_layer.cpp, line 306 [ERROR:0] input[0] = [ 1 4 510 510 ] [ERROR:0] blobs[0] = CV_32FC1 [ 32 3 3 3 ] [ERROR:0] Exception message: OpenCV(3.4.11) /build/3_4_pack-android/opencv/modules/dnn/src/layers/convolution_layer.cpp:306: error: (-2:Unspecified error) Number of input channels should be multiple of 3 but got 4 in function 'virtual bool cv::dnn::ConvolutionLayerImpl::getMemoryShapes(const std::vector<std::vector<int> >&, int, std::vector<std::vector<int> >&, std::vector<std::vector<int> >&) const' E/org.opencv.dnn: dnn::forward_14() caught cv::Exception: OpenCV(3.4.11) /build/3_4_pack-android/opencv/modules/dnn/src/layers/convolution_layer.cpp:306: error: (-2:Unspecified error) Number of input channels should be multiple of 3 but got 4 in function 'virtual bool cv::dnn::ConvolutionLayerImpl::getMemoryShapes(const std::vector<std::vector<int> >&, int, std::vector<std::vector<int> >&, std::vector<std::vector<int> >&) const'

I tried to change the size to to 512X512, 1024x980, it not helped.