Using cascade classifiers to detect objects
In this section, we will use a cascade classifier to detect closed palms in your phone's camera feed, but first, we will have to touch on how to access your phone's camera using OpenCV.
Accessing your phone's camera using OpenCV
We will first create a new application with one blank activity named AutoSelfie
, following the same steps that we used in the previous chapters.
For the application to access the phone's camera and be able to save pictures, you will need to add the following two permissions in the manifest file:
<uses-permissionandroid:name="android.permission.CAMERA"/> <uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
You can find the rest of the configurations with the code bundle provided with this chapter.
A camera preview
OpenCV provides a Java implementation for a camera preview class that handles the interaction between the device camera and OpenCV library. The org.opencv.android.JavaCameraView
class...