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 ...

Get OpenCV Android Programming By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.