Ask Your Question

Revision history [back]

IMREAD PATH

I'm trying to do a face detecction aplicattion with opencv, and I'm facing a problem with the path of the image that I want to pass as parameter, to test the face detecction. I don't know which directory I have to paste my image, and how can I read it, to pass to the imread. plus, do I need to ask any request like access to the external storage or something?

This is the code of the imread: System.loadLibrary(Core.NATIVE_LIBRARY_NAME); try {

            File imgDir = getDir("imagens_teste", Context.MODE_PRIVATE);
            File cara = new File(imgDir, "cara.jpg");

            Mat imagemColorida = imread(cara.getAbsolutePath());
            Mat imagemCinza = new Mat();

I already tried this: File root = Environment.getRootDirectory(); File file = new File(root, "cara.jpg");

            Mat imagemColorida = imread(file.getAbsolutePath());
            Mat imagemCinza = new Mat();

and Mat imagemColorida = imread("src\main\imagens_teste\cara.jpg");

can someone help me?

IMREAD PATH

I'm trying to do a face detecction aplicattion with opencv, and I'm facing a problem with the path of the image that I want to pass as parameter, to test the face detecction. I don't know which directory I have to paste my image, and how can I read it, to pass to the imread. plus, do I need to ask any request like access to the external storage or something?

This is the code of the imread: System.loadLibrary(Core.NATIVE_LIBRARY_NAME); try {imread:

 System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
            try {

                File imgDir = getDir("imagens_teste", Context.MODE_PRIVATE);
             File cara = new File(imgDir, "cara.jpg");

             Mat imagemColorida = imread(cara.getAbsolutePath());
             Mat imagemCinza = new Mat();

I already tried this: File root = Environment.getRootDirectory(); File file = new File(root, "cara.jpg");

File root = Environment.getRootDirectory();
            File file = new File(root, "cara.jpg");


            Mat imagemColorida = imread(file.getAbsolutePath());
            Mat imagemCinza = new Mat();

and Mat imagemColorida = imread("src\main\imagens_teste\cara.jpg");imread("src\\main\\imagens_teste\\cara.jpg");

can someone help me?