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:
- In AndroidCamera.java let us create a new method called initCamera().
- 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).
- Moreover, in this method, we have to initialize an image container ...