CameraScanner.Maui
1.4.6-pre
See the version list below for details.
dotnet add package CameraScanner.Maui --version 1.4.6-pre
NuGet\Install-Package CameraScanner.Maui -Version 1.4.6-pre
<PackageReference Include="CameraScanner.Maui" Version="1.4.6-pre" />
paket add CameraScanner.Maui --version 1.4.6-pre
#r "nuget: CameraScanner.Maui, 1.4.6-pre"
// Install CameraScanner.Maui as a Cake Addin #addin nuget:?package=CameraScanner.Maui&version=1.4.6-pre&prerelease // Install CameraScanner.Maui as a Cake Tool #tool nuget:?package=CameraScanner.Maui&version=1.4.6-pre&prerelease
CameraScanner.Maui
This library offers camera preview and barcode scanning functionality for .NET MAUI apps using native platform APIs with Google ML Kit and Apple VisionKit.
Download and Install CameraScanner.Maui
This library is available on NuGet: https://www.nuget.org/packages/CameraScanner.Maui Use the following command to install Plugin.FirebasePushNotifications using NuGet package manager console:
PM> Install-Package CameraScanner.Maui
You can use this library in any .NET MAUI project compatible to .NET 8 and higher.
App Setup
- This plugin provides an extension method for MauiAppBuilder
UseCameraScanner
which ensure proper startup and initialization. Call this method within yourMauiProgram
just as demonstrated in the CameraDemoApp:var builder = MauiApp.CreateBuilder() .UseMauiApp<App>() .UseCameraScanner();
- Add camera permission for Android in your
AndroidManifest.xml
file. Add the followinguses-permission
entry inside of themanifest
node:<uses-permission android:name="android.permission.CAMERA" />
- Add camera permission for iOS in your
Info.plist
file. Add the following permission inside of thedict
node:
Permission strings can also be localized on iOS using lproj-folders and InfoPlist.strings files. Read this if you're interested in this topic.<key>NSCameraUsageDescription</key> <string>Required to display camera preview and scan barcodes.</string>
API Usage
The following documentation guides you trough the most important use cases of this library. Not all aspects are covered. If you think there is something important missing here, feel free to open a new issue.
This documentation only demonstrates the use of CameraScanner.Maui within a XAML and MVVM based app. Of course, the code also runs in C# and code-behind UIs.
Use CameraView in XAML
In order to add the camera preview control CameraView
to your xaml page, you need to add the xml namespace in the root of your xaml file:
xmlns:c="http://camerascanner.maui"
Then, you can add CameraView
to your xaml UI.
<c:CameraView />
There are several bindable properties in CameraView
in order to configure and control the camera preview.
Configure CameraView
Property | Description |
---|---|
AutoDisconnectHandler |
Defines if the platform handler is automatically disconnected or if Handler.DisconnectHandler(); is called manually. Default: true (automatically disconnected) |
VibrationOnDetected |
Enables or disables vibration on successful barcode detection. Default: false |
CameraEnabled |
Enables or disables the camera preview. Default: true |
PauseScanning |
Pauses barcode scanning. |
ForceInverted |
Forces scanning of inverted barcodes. Reduces performance significantly. Android only. |
PoolingInterval |
Enables pooling of detections for better detection of multiple barcodes at once. Value in milliseconds. Default: 0 (disabled). |
TorchOn |
Enables or disables the torch. |
TapToFocusEnabled |
Disables or enables tap-to-focus. |
CameraFacing |
Select front or back facing camera. Default: CameraFacing.Back |
CaptureQuality |
Set the capture quality for the image analysis. Recommended and default value is Medium. Use the highest values for more precision or lower for fast scanning. |
BarcodeFormats |
Set the enabled barcode formats. Default: BarcodeFormats.All . |
AimMode |
Disables or enables aim mode. When enabled only barcode that is in the center of the preview will be detected. |
ViewfinderMode |
Disables or enables viewfinder mode. When enabled only barcode that is visible in the preview will be detected. |
CaptureNextFrame |
Captures the next frame from the camera feed. |
BarcodeDetectionFrameRate |
Specifies the frequency at which frames are processed for barcode detection. Default: null (no frame skipping) Example: If the value is null, 0 or 1, every frame from the camera preview is analyzed. If the value is 2, every 2nd frame from the camera preview is analyzed. If the value is 3, every 3rd frame from the camera preview is analyzed. |
RequestZoomFactor |
Setting this value changes the zoom factor of the camera. Value has to be between MinZoomFactor and MaxZoomFactor. More info: iOS/macOS - https://developer.apple.com/documentation/avfoundation/avcapturedevice/zoom Android - https://developer.android.com/reference/kotlin/androidx/camera/view/CameraController#setZoomRatio(float) Only logical multi-camera is supported - https://developer.android.com/media/camera/camera2/multi-camera |
CurrentZoomFactor |
Returns current zoom factor value. |
MinZoomFactor |
Returns minimum zoom factor for current camera. |
MaxZoomFactor |
Returns maximum zoom factor for current camera. |
DeviceSwitchZoomFactors |
Returns zoom factors that switch between camera lenses. Supported on iOS only. |
Ask for camera permission
Before your app is allowed to access the camera stream, the user has to give runtime permission to access the camera. This library provides the interface ICameraPermissions
to check if the permission is already given and/or to ask for permission.
Access ICameraPermissions
via static singleton instance CameraPermissions.Current
or inject it using dependency injection.
IBarcodeScanner
tbd
Supported Barcode Formats
The following barcode formats are supported on the underlying platforms:
Barcode Format | Supported on iOS | Supported on Android |
---|---|---|
Aztec | ✅ | ✅ |
Code128 | ✅ | ✅ |
Code39 | ✅ | ✅ |
Code93 | ✅ | ✅ |
DataMatrix | ✅ | ✅ |
Ean13 | ✅ | ✅ |
Ean8 | ✅ | ✅ |
ITF | ✅ | ✅ |
Pdf417 | ✅ | ✅ |
QR | ✅ | ✅ |
UPC_A | ✅ | ✅ |
UPC_E | ✅ | ✅ |
Codabar | ✅ *1) | ✅ |
GS1DataBar | ✅ *1) | ⬜ |
GS1DataBarExpanded | ✅ *1) | ⬜ |
GS1DataBarLimited | ✅ *1) | ⬜ |
I2of5 | ✅ | ⬜ |
MicroQR | ✅ *1) | ⬜ |
MicroPdf417 | ✅ *1) | ⬜ |
*1) Supported on iOS 15 and later.
Contribution
Contributors welcome! If you find a bug or you want to propose a new feature, feel free to do so by opening a new issue on github.com.
Links
Product | Versions 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-ios17.0 is compatible. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Maui.Controls (>= 8.0.3)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.3)
-
net8.0-android34.0
- Microsoft.Maui.Controls (>= 8.0.3)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.3)
- Xamarin.AndroidX.Activity.Ktx (>= 1.9.0.3)
- Xamarin.AndroidX.Camera.Camera2 (>= 1.3.4)
- Xamarin.AndroidX.Camera.View (>= 1.3.4)
- Xamarin.AndroidX.Collection.Ktx (>= 1.4.0.4)
- Xamarin.AndroidX.Lifecycle.Process (>= 2.8.2.1)
- Xamarin.AndroidX.Lifecycle.Runtime (>= 2.8.2.1)
- Xamarin.AndroidX.Lifecycle.Runtime.Ktx (>= 2.8.2.1)
- Xamarin.AndroidX.Lifecycle.ViewModel (>= 2.8.2.1)
- Xamarin.AndroidX.Lifecycle.ViewModel.Ktx (>= 2.8.2.1)
- Xamarin.Google.MLKit.BarcodeScanning (>= 117.2.0.6)
-
net8.0-ios17.0
- Microsoft.Maui.Controls (>= 8.0.3)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.3)
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.24-pre | 28 | 11/1/2024 |
1.4.21-pre | 84 | 10/10/2024 |
1.4.19 | 371 | 10/2/2024 |
1.4.14-pre | 68 | 10/1/2024 |
1.4.12-pre | 66 | 10/1/2024 |
1.4.11-pre | 68 | 10/1/2024 |
1.4.7-pre | 62 | 10/1/2024 |
1.4.6-pre | 63 | 9/30/2024 |
1.4.3-pre | 77 | 9/29/2024 |
1.4.0-pre | 75 | 9/23/2024 |
1.3.29 | 197 | 9/19/2024 |
1.3.22-pre | 87 | 9/13/2024 |
1.3.18-pre | 78 | 9/12/2024 |
1.3.15-pre | 101 | 9/11/2024 |
1.3.13-pre | 93 | 9/10/2024 |
1.3.11-pre | 95 | 9/3/2024 |
1.3.10-pre | 88 | 9/3/2024 |
1.3.7-pre | 71 | 9/1/2024 |
1.3.6 | 735 | 8/14/2024 |
1.3.2-pre | 122 | 8/13/2024 |
1.2.4 | 128 | 8/12/2024 |
1.2.1-pre | 87 | 8/12/2024 |
1.1.20 | 114 | 8/8/2024 |
1.1.17-pre | 93 | 8/8/2024 |
1.1.13-pre | 58 | 8/1/2024 |
1.1.12-pre | 54 | 8/1/2024 |
1.1.0-pre | 140 | 7/22/2024 |
1.0.49 | 119 | 7/16/2024 |
1.0.0 | 111 | 7/3/2024 |
1.4
- Optimize camera device selection on iOS.
- Optimize default zoom selection on iOS.
1.3
- Cleanup ICameraPermissions interface, add static Current to ICameraPermissions.
- Add support for AppShell apps.
1.2
- Automatically call DisconnectHandler if CameraView is no longer used on a ContentPage.
1.1
- Internal refactorings and stability improvements.
1.0
- Initial release.