Ask Your Question

Revision history [back]

Android OpenCV reverts to Caffe instead of Tensorflow DNN

Hello all, I was writing a fragment of an Android app which takes advantage of the OpenCV DNN module. However, I there are very strange errors which I keep receiving because I keep receiving this error for reading a network from Caffe instead of Tensorflow: CvException - cv::Exception: OpenCV(4.1.0) /build/master_pack_android/opencv/modules/dnn/src/caffe/caffe_io.cpp:1132: error: (-2:Unspecified error) FAILED: fs.is_open(). Can't open "src/main/java/org/firstinspires/ftc/teamcode/model.pbtxt" in function 'ReadProtoFromBinaryFile. This is especially strange considering that my code below does not use Caffe for anything. All the binary files are Tensorflow based and does not even import Caffe files whatsoever. Below is the code I used:

class NeuralNet
{
    private Net net;
    private String pbTxt = "src/main/java/org/firstinspires/ftc/teamcode/model.pb";
    private String pbFile = "src/main/java/org/firstinspires/ftc/teamcode/model.pbtxt";

    @Override
    public Mat processFrame(Mat input)
    {

        net = Dnn.readNetFromTensorflow(pbFile, pbTxt);
        system.addLine("[INFO]: Model successfully loaded!");

        return input;
    }
}

Please keep in mind that this is just the initialization class for the DNN. The rest of the initializations are in other files. Please help me out because I have done whatever I could to troubleshoot the issue however there seems to be nothing wrong with the code in anyway because all it is doing is throwing the same error no matter whatever I try. Is Tensorflow DNN module not supported on Android?