XDev.CameraMaui 1.4.15.3

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package XDev.CameraMaui --version 1.4.15.3
                    
NuGet\Install-Package XDev.CameraMaui -Version 1.4.15.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XDev.CameraMaui" Version="1.4.15.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="XDev.CameraMaui" Version="1.4.15.3" />
                    
Directory.Packages.props
<PackageReference Include="XDev.CameraMaui" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add XDev.CameraMaui --version 1.4.15.3
                    
#r "nuget: XDev.CameraMaui, 1.4.15.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package XDev.CameraMaui@1.4.15.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=XDev.CameraMaui&version=1.4.15.3
                    
Install as a Cake Addin
#tool nuget:?package=XDev.CameraMaui&version=1.4.15.3
                    
Install as a Cake Tool

Camera.MAUI

A Camera View control and a Barcode Endode/Decode control (based on ZXing.Net) for .NET MAUI applications.

Latest release <a href="https://www.nuget.org/packages/XDev.CameraMaui"> <img src="https://img.shields.io/nuget/v/XDev.CameraMaui"></a>

Latest build    <a href="https://www.nuget.org/packages/XDev.CameraMaui"> <img src="https://img.shields.io/nuget/vpre/XDev.CameraMaui"></a>    status    <a href="https://dev.azure.com/xdevapps/XDev.Maui/_build?definitionId=86"> <img src="https://dev.azure.com/xdevapps/XDev.Maui/_apis/build/status/XDev.CameraMaui-CI"></a>

<br>

source repo

github mirror mirror sync status Build Status

Forked from : https://github.com/janusw/CameraMaui at v. 1.4.12

CameraView

A ContetView control for camera management with the next properties:

Android iOS/Mac Windows
Preview ✅ ✅ ✅
Mirror preview ✅ ✅ ✅
Flash ✅ ✅ ✅
Torch ✅ ✅ ✅
Zoom ✅ ✅ ✅
Take snapshot ✅ ✅ ✅
Save snapshot ✅ ✅ ✅
Barcode detection/decode ✅ ✅ ✅
Video/audio recording ✅ ✅ ✅
Take Photo ✅ ✅ ✅

Install and configure CameraView

  1. Download and Install Latest release <a href="https://www.nuget.org/packages/XDev.CameraMaui"> <img src="https://img.shields.io/nuget/v/XDev.CameraMaui"></a> NuGet package on your application.

  2. Initialize the plugin in your MauiProgram.cs:

     // Add the using to the top
     using Camera.MAUI;
    
     public static MauiApp CreateMauiApp()
     {
     	var builder = MauiApp.CreateBuilder();
    
     	builder
     		.UseMauiApp<App>()
     		.UseMauiCameraView(); // Add the use of the plugging
    
     	return builder.Build();
     }
    
  3. Add camera/microphone permissions to your application:

Android

In your AndroidManifest.xml file (Platforms\Android) add the following permission:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.RECORD_VIDEO" />

iOS/MacCatalyst

In your info.plist file (Platforms\iOS / Platforms\MacCatalyst) add the following permission:

<key>NSCameraUsageDescription</key>
<string>This app uses camera for...</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app needs access to the microphone for record videos</string>

Make sure that you enter a clear and valid reason for your app to access the camera. This description will be shown to the user.

Windows

In your Package.appxmanifest file (Platforms\Windows) go to Capabilities and mark Web Camera and Microphone.

For more information on permissions, see the Microsoft Docs.

Using CameraView

In XAML, make sure to add the right XML namespace:

xmlns:cv="clr-namespace:Camera.MAUI;assembly=Camera.MAUI"

Use the control:

<cv:CameraView x:Name="cameraView" WidthRequest="300" HeightRequest="200"/>

Configure the events:

		cameraView.CamerasLoaded += CameraView_CamerasLoaded;
		cameraView.BarcodeDetected += CameraView_BarcodeDetected;

Configure the camera and microphone to use:

	private void CameraView_CamerasLoaded(object sender, EventArgs e)
	{
		if (cameraView.NumCamerasDetected > 0)
		{
			if (cameraView.NumMicrophonesDetected > 0)
				cameraView.Microphone = cameraView.Microphones.First();
			cameraView.Camera = cameraView.Cameras.First();
			MainThread.BeginInvokeOnMainThread(async () =>
			{
				if (await cameraView.StartCameraAsync() == CameraResult.Success)
				{
					controlButton.Text = "Stop";
					playing = true;
				}
			});
		}
	}

CameraInfo type (Camera Property): CameraInfo has the next properties:

	public string Name
	public string DeviceId
	public CameraPosition Position
	public bool HasFlashUnit
	public float MinZoomFactor
	public float MaxZoomFactor
	public List<Size> AvailableResolutions

Start camera playback:

		 if (await cameraView.StartCameraAsync(new Size(1280, 720)) == CameraResult.Success)
		 {
			 playing = true;
		 }

Stop camera playback:

		 if (await cameraView.StopCameraAsync() == CameraResult.Success)
		 {
			 playing = false;
		 }

Set Flash mode

cameraView.FlashMode = FlashMode.Auto;

Toggle Torch

cameraView.TorchEnabled = !cameraView.TorchEnabled;

Set mirrored mode

Notes for v 1.4.14 and later:

  • All platforms have FrontCamera with this true by default. BackCamera with this false by default.
  • The value sticks to the camera (CameraInfo instance) so if you change the CameraView.MirroredImage property, the value is set to the currently displayed camera (CameraInfo) available via CameraView.Camera.)
  • In most cases, you won't need to set this property unless you want to override the default behavior.
cameraView.MirroredImage = true;
// or
cameraInfo.IsMirrored = true;
// or
cameraView.Camera.IsMirrored = true;

Set zoom factor

if (cameraView.MaxZoomFactor >= 2.5f)
	cameraView.ZoomFactor = 2.5f;

Get a snapshot from the playback

ImageSource imageSource = cameraView.GetSnapShot(ImageFormat.PNG);
bool result = cameraView.SaveSnapShot(ImageFormat.PNG, filePath);

Record a video:

var result = await cameraView.StartRecordingAsync(Path.Combine(FileSystem.Current.CacheDirectory, "Video.mp4"), new Size(1920, 1080));
....
result = await cameraView.StopRecordingAsync();

Take a photo

var stream = await cameraView.TakePhotoAsync();
if (stream != null)
{
	var result = ImageSource.FromStream(() => stream);
	snapPreview.Source = result;
}

Use Control with MVVM: The control has several binding properties for take an snapshot:

	/// Binding property for use this control in MVVM.
	public CameraView Self

	/// Sets how often the SnapShot property is updated in seconds.
	/// Default 0: no snapshots are taken
	/// WARNING! A low frequency directly impacts over control performance and memory usage (with AutoSnapShotAsImageSource = true)
	/// </summary>
	public float AutoSnapShotSeconds
	
	/// Sets the snaphost image format
	public ImageFormat AutoSnapShotFormat

	/// Refreshes according to the frequency set in the AutoSnapShotSeconds property (if AutoSnapShotAsImageSource is set to true) or when GetSnapShot is called or TakeAutoSnapShot is set to true
	public ImageSource SnapShot
	
	/// Refreshes according to the frequency set in the AutoSnapShotSeconds property or when GetSnapShot is called.
	/// WARNING. Each time a snapshot is made, the previous stream is disposed.
	public Stream SnapShotStream
	
	/// Change from false to true refresh SnapShot property
	public bool TakeAutoSnapShot
	
	/// If true SnapShot property is refreshed according to the frequency set in the AutoSnapShotSeconds property
	public bool AutoSnapShotAsImageSource
	/// Starts/Stops the Preview if camera property has been set
	public bool AutoStartPreview
	{
		get { return (bool)GetValue(AutoStartPreviewProperty); }
		set { SetValue(AutoStartPreviewProperty, value); }
	}
	/// Full path to file where record video will be recorded.
	public string AutoRecordingFile
	{
		get { return (string)GetValue(AutoRecordingFileProperty); }
		set { SetValue(AutoRecordingFileProperty, value); }
	}
	/// Starts/Stops record video to AutoRecordingFile if camera and microphone properties have been set
	public bool AutoStartRecording
	{
		get { return (bool)GetValue(AutoStartRecordingProperty); }
		set { SetValue(AutoStartRecordingProperty, value); }
	}
<cv:CameraView x:Name="cameraView" WidthRequest="300" HeightRequest="200"
  BarCodeOptions="{Binding BarCodeOptions}" 
  BarCodeResults="{Binding BarCodeResults, Mode=OneWayToSource}"
  Cameras="{Binding Cameras, Mode=OneWayToSource}" Camera="{Binding Camera}" 
  AutoStartPreview="{Binding AutoStartPreview}" 
  NumCamerasDetected="{Binding NumCameras, Mode=OneWayToSource}"
  AutoSnapShotAsImageSource="True" AutoSnapShotFormat="PNG" 
  TakeAutoSnapShot="{Binding TakeSnapshot}" AutoSnapShotSeconds="{Binding SnapshotSeconds}"
  Microphones="{Binding Microphones, Mode=OneWayToSource}" Microphone="{Binding Microphone}"
  NumMicrophonesDetected="{Binding NumMicrophones, Mode=OneWayToSource}"
  AutoRecordingFile="{Binding RecordingFile}" 
  AutoStartRecording="{Binding AutoStartRecording}"/>

You have a complete example of MVVM in MVVM Example

Enable and Handle barcodes detection:

	cameraView.BarcodeDetected += CameraView_BarcodeDetected;
	cameraView.BarCodeOptions = new ZXingHelper.BarcodeDecodeOptions
	{
		AutoRotate = true,
		PossibleFormats = { ZXing.BarcodeFormat.QR_CODE },
		ReadMultipleCodes = false,
		TryHarder = true,
		TryInverted = true
	};
	cameraView.BarCodeDetectionFrameRate = 10;
	cameraView.BarCodeDetectionMaxThreads = 5;
	cameraView.ControlBarcodeResultDuplicate = true;
	cameraView.BarCodeDetectionEnabled = true;

	private void CameraView_BarcodeDetected(object sender, ZXingHelper.BarcodeEventArgs args)
	{
		Debug.WriteLine("BarcodeText=" + args.Result[0].Text);
	}

Use the event or the bindable property BarCodeResults

	/// Event launched every time a code is detected in the image if "BarCodeDetectionEnabled" is set to true.
	public event BarcodeResultHandler BarcodeDetected;
	/// It refresh each time a barcode is detected if BarCodeDetectionEnabled porperty is true
	public Result[] BarCodeResults

BarcodeImage

A ContentView control for generate codebars images.

In XAML, make sure to add the right XML namespace:

xmlns:cv="clr-namespace:Camera.MAUI;assembly=Camera.MAUI"

Use the control and its bindable properties:

<cv:BarcodeImage x:Name="barcodeImage" Aspect="AspectFit"
				 WidthRequest="400" HeightRequest="400" 
				 BarcodeWidth="200" BarcodeHeight="200" BarcodeMargin="5"
				 BarcodeBackground="White" BarcodeForeground="Blue"
				 BarcodeFormat="QR_CODE" />

Set the barcode property to generate the image:

barcodeImage.Barcode = "https://github.com/hjam40/Camera.MAUI";
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-android34.0 is compatible.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-ios18.0 is compatible.  net8.0-maccatalyst was computed.  net8.0-maccatalyst18.0 is compatible.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net8.0-windows10.0.19041 is compatible.  net9.0 is compatible.  net9.0-android was computed.  net9.0-android35.0 is compatible.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-ios18.0 is compatible.  net9.0-maccatalyst was computed.  net9.0-maccatalyst18.0 is compatible.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net9.0-windows10.0.19041 is compatible.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.4.16-alpha001 162 3/25/2026
1.4.15.3 463 3/25/2026
1.4.15-alpha002 138 3/20/2026
1.4.15-alpha001 1,476 10/22/2025
1.4.14.5 329 10/20/2025
1.4.14-alpha004 234 10/17/2025
1.4.14-alpha002 250 10/8/2025
1.4.14-alpha001 245 10/8/2025
1.4.13.3 361 9/25/2025
1.4.13-alpha002 389 9/18/2025
1.4.13-alpha001 377 9/18/2025

- Cameras' mirrored state now tracks the camera and is reflected in the CameraView.MirroredImage property, as well as CameraInfo.IsMirrored and can be changed by either object, see readme for more details.
- Android fixed several race conditions regarding starting/stopping cameras that caused various crashes:
- https://xdevapps.visualstudio.com/XDev.Maui/_workitems/edit/172
- https://github.com/janusw/CameraMaui/issues/47
- https://github.com/jasells/CameraMaui/issues/1