This error appear when project steps into detectMultiScale method in my project. I’m using the haarcascade_eye.xml file in my CascadeClassifier class. I have this xml file in assets folder in to project folder, but I don’t know why I have this error?
My haarcascade file is not zipped, I put it right in My project folder like this C:\Users\user\MyProject\app\main\src\assets\haarcascade_eye.xml file, and use this path in my code.
again, when building the apk, that asset folder will end up, zipped, inside of the apk.
c-code, like fopen() cannot reach it there (different to java !)
similar problem for nn models, pretrained tracker files, anything you’d just load ‘from disk’ on a pc.
when you compile / build your program, your phone is not present, so no hd / sdcard to put it, that’s why such files end up (temporary) in your ‘assets’ folder in your project
Yes, this is sense to me very much. I’m real didn’t know how I can use the cascade file in my android project on android device. Have you some samples how it’s sovle by someone else, or maybe you have some links when I can find the solution of this problem?
So what I need to do? I see the sample in the link which you are send me, but I not sure that I can use this in my android project. I copy/paste this code, but there is many moments wich I can uderstand, like InputStream is = getResources().openRawResource(R.raw.lbpcascade_frontalface). I’m real don’t know what are raw is this…
I don’t have the /res/raw folder in my project, the studio ask me to create the raw resouse file haarcascade_eye.xml but there no raw folder, I can create that file in some others folders like values, xml, drawable and etc. May I create the raw folder by my self like New-folder-raw and then put this raw folder in my res folder?
In this sample I don’t see how I can put this is the /tmp or /sdcard. How I can do this? I doing my project on computer, not on phone, so I have all files on computer, and I don’t know how I can put this file in tmp folder. If I need that my app will be installed on many devices, I can’t copy this file in the tmp folder in each device, how can I do this automaticly? What information I need take from this sample? This sample have in opencv java folder wich I download from opencv.org, but I don’t know what I need to see in this code, what can help me find the soution.
There are 2 methods here that cannot be recognized: getResources(), getDir() what should I do with them? The studio says that I need to declare them in the class, I do it, but they both return null, what should I do in this case? I already tried this example code, I understand what it does, but these methods don’t work…
apart from your current, android coding problems (where we can’t help, probably) –
i have no idea, what your app does in the end, but trying to find eyes using cascades without a previous face detection (and restricting eye-search to that region) will be terribly inaccurate.
keep an eye on FaceDetectorYN (OpenCV 4.7.0 Java documentation) , which returns face rects + 5 landmarks (eyes, nose, mouth)
(however, same problem with android, it needs external pretrained models / resources, …)