Search code examples
xamarinxamarin.formsxamarin.androidxamarin.ios

How can I capture an image from a preview video stream from the device camera using custom renderer view xamarin forms


I'm implementing biometric facial authentication in my Xamarin.forms app (Android and iOS). I am basing myself on this example to capture the user's face which implements custom renderer (Android), but in this example: https://github.com/UNIT-23/Xam-Android-Camera2-Sample the image must be touched to capture it, I would like to capture this image every 3 seconds without the user having to touch, like second option I would like to capture the photo with a button, but I don't really know how to implement it, so any help or example suggestions would be greatly appreciated.

Thanks in advance for your help and your time!


Solution

  • check

    Alternatively, for Xamarin.Forms, you have access to a cross-platform Timer via the Device class:

    Device.StartTimer(TimeSpan.FromSeconds(1), () =>
    {
        // called every 1 second
        // do stuff here
    
        return true; // return true to repeat counting, false to stop timer
    });