Being able to use the camera and adding pictures to your app is useful not only for ML but also for several other features you might want to add to your app. You can leverage the camera plugin to get a list of the available cameras in the device and take photos or videos.
With the camera plugin, you get access to two useful objects:
- CameraController connects to a device's camera and you use it to take pictures or videos.
- CameraDescription contains the properties of a camera device, including its name and orientation.
Most devices have two cameras, one on the front (for selfies) and the other on the back, but some devices may only have one, and others more than two when they connect an external camera. That’s why in our code we created a dynamic List of CameraDescription objects to make the user choose the camera they want to use with the following instruction:
cameras = await availableCameras();