Taskito offers simple and intuitive tools to organize your daily tasks and to-do list. It combines features of project management software with productivity and time management tools. Try it out now!
Face Detection using OpenCV Haarcascades in Android
on Android
I was working on this app which required face detection and pose estimation. I was already using Native code for some other processes (edge detection, etc) so I figured I’d use Haarcascades in native code only. It was a bit of hassle to configure how to send xml file to JNI or whether it would load the cascade once I pass the filename to the native code.
So I looked around a bit. I tried to look into the examples provided with opencv sdk and found out that I had to write the whole xml file to FileOutputStream so that it could be accessed in the native code.
Making XML available to the native code
First I stored the XML file in assets/ folder.
Once this is done, you can pass the file and relevant Mat objects to the native code.
JNI call
Native code
I’m not editing the native function name here so you need to change it appropriately.
This returns if face is found or not. If face is found it draws on the retvalMat.
So this was pretty easy to do and return a good output.
P.S. Learning more about Android OpenCV.
Playing around with Android UI
Articles focusing on Android UI - playing around with ViewPagers, CoordinatorLayout, meaningful motions and animations, implementing difficult customized views, etc.