Camera and Photo Access - KeithWilliamsGMIT/4th-Year-Mobile-Application-Development-Project GitHub Wiki

Overview

One of the requirements of this project was to allow the user to upload an image of a receipt. This means that the application must be able to use the device camera for taking a photo or access the device storage for browsing for a photo. These are both native device operations, meaning platform specific code must be implemented.

Camera

Just a note on the camera. When using a camera in an application you have the choice of creating an in-app camera or using an external camera app. The advantage of the in-app camera is that the user doesn't need to install a camera app. The advantage of using an external camera app is that the quality of the photo is generally higher, extra functionality like zoom, crop and flash, and it takes less time to implement. For these reasons I've chosen to use an external camera app seeing as the majority of, if not all, users would have a camera app installed and the photos must be a of high quality as the text will be extracted from them.

Plugins

To avoid implementing this platform specific code I decided to use Xam.Media.Plugin. This offers camera and browsing functionality that can be implemented solely in the shared project. This made getting a photo from the user significantly easier.

Permissions

Finally, for all of this to work, the application must specify what permissions it needs. This is done in separately in each project. In the UWP project, open the Package.appxmanifest file and navigate to the capabilities tab. Under capabilities, select Webcam. Save the file. In the Android project, open properties and navigate to the Android Manifest tab. Scroll down to required permissions and select Camera. Save the file.