O'Reilly logo

Android Things Projects by Francesco Azzola

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting ready to use the camera

Before using the camera, we have to detect it and make sure it is connected to the Android Things board. For this purpose, we will use the CameraManager class:

  1. In AndroidCamera.java let us create a new method called initCamera().

 

  1. In this method, we first get the reference to the camera manager and then the app enumerates all the connected cameras:
        cManager = (CameraManager)         ctx.getSystemService(Context.CAMERA_SERVICE);            try {            String[] idCams = cManager.getCameraIdList();            camId = idCams[0];            }           catch (CameraAccessException e) {            e.printStackTrace();           }

In this project, we will use the first camera detected (as you can notice we use 0 as index).

  1. Moreover, in this method, we have to initialize an image container ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required