1

I need to call the OpenCV function readNetFromDarknet but I am getting the data from an Asset's InputStream as shown in the code below

I am able to correctly parse the class names from the coco.names asset using BufferedReader, However, I cannot explicitly pass the "yolov4-tiny.cfg" and "yolov4-tiny.weights" InputStreams to the readNetFromDarknet function.

How can I appropriately call this function? Is there a path to these assets that I can use? Or do I need to first export the assets as files onto the android device from the input stream and then call the function?

public DNN(Context m_context){

    AssetManager assetManager = m_context.getAssets();

    try {
        InputStream ims1 = assetManager.open("coco.names");
        InputStream ims2 = assetManager.open("yolov4-tiny.cfg");
        InputStream ims3 = assetManager.open("yolov4-tiny.weights");
        classes = new BufferedReader(new InputStreamReader(ims1, StandardCharsets.UTF_8)).lines().collect(Collectors.toList());
    }
    catch(IOException e) {
        e.printStackTrace();
    }

    net = Dnn.readNetFromDarknet("yolov4-tiny.cfg", "yolov4-tiny.weights");
}
Mich
  • 3,188
  • 4
  • 37
  • 85

0 Answers0