Most, if not all, mobile phone devices running Android are equipped with a video-capable camera, and the Android OS provides APIs to access the raw data stream from it. Up until Android version 5 (API level 21), Google recommended using the older Camera API; however, in recent versions, the API was deprecated in favor of the new Camera2 API, which we will use. A good example guide for using the Camera2 API is provided for Android developers by Google: https://github.com/googlesamples/android-Camera2Basic. In this section, we will only recount a few important elements, and the complete code can be viewed in the accompanying repository.
First, using the camera requires user permissions. In the AndroidManifest.xml file, we flag the following:
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android...