Sometimes the basic camera intents aren't enough, or we are creating an augmented reality game, and we want to process the images as the camera streams them.
To create a camera app, or some other app that displays a live preview from the camera hardware, we need to set up several things similar to playing a video, we must implement the ISurfaceHolderCallback
interface, which will manage the live preview:
As with using intents to start the camera, we need to check for the existence of a camera on the device. Additionally, we will need to request permission to manage the camera, as follows:
[assembly: UsesPermission(Manifest.Permission.Camera)]
Next, we will need a surface to display the camera preview, and to do this, we will need an instance of the
ISurfaceHolderCallback
interface:public class MainActivity : Activity, ISurfaceHolderCallback { private ISurfaceHolder surfaceHolder; public void SurfaceChanged( ISurfaceHolder holder, Format format,...