Camera view sample

In this section we'll extend our empty OpenCV app created in the previous section to support camera. We'll take camera frames and display them on the screen.

  1. Tell a system that we need camera permissions. Add the following code to the file MyApplication/app/src/main/AndroidManifest.xml :
  1. <uses-permission android:name="android.permission.CAMERA"/>
    <uses-feature android:name="android.hardware.camera" android:required="false"/>
    <uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
    <uses-feature android:name="android.hardware.camera.front" android:required="false"/>
    <uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>
    Like this:

  1. Go to activity_main.xml layout and delete TextView with text "Hello World!"

This can also be done in Code or Split mode by removing the TextView block from XML file.

  1. Add camera view to the layout:

    1. Add a scheme into layout description:
  • xmlns:opencv=""