Comments (5)
Hi! Thank you for your feedback.
This error could be for different reasons... Maybe you has not set the Camera property before call StartCameraAsync? You can try to set MirroredImage property to True before call StartCameraAsync, in android thats changes the PreviewView implementation mode to compatible and maybe it works better in Samsung devices...
Another reason could be an exception when the plugging tries to open the camera, you could clone this git repository and run in debug mode the test program included in your device
from camera.maui.
Hi Hector,
Thanks for the quick reply.
I found the reason. That's because I use ZXing.net.maui to process the barcode on the page before I use Camera.maui.
Apparently, ZXing.net.maui doesn't stop the barcodereaderview automatically, and I didn't find any function to stop it.
Do you have the experience on ZXing.net.maui? Do you know how to stop the barcodereaderview?
After I successfully open the camera, I am going to take a snapshot and save it to a variable.
And then I am going to show it on the image control of next page.
To do that, I call "GetSnapShot". As it returns "ImageSource", I must convert it to Base64 string.
Here is the code.
var imageSource = cameraView.GetSnapShot(ImageFormat.PNG);
var imageSourceStream = await ((StreamImageSource)imageSource).Stream(CancellationToken.None);
using var memoryStream = new MemoryStream();
imageSourceStream.CopyTo(memoryStream);
weighRecord.Picture = Convert.ToBase64String(memoryStream.ToArray());
On the next page, I convert Base64 string back to image source.
var imageBytes = Convert.FromBase64String(weighRecord.Picture);
using MemoryStream memoryStream = new(imageBytes);
contaminationPicture.Source = ImageSource.FromStream(() => memoryStream);
Unfortunately, it doesn't work. Do you know how to show the snapshot in the image control?
Thank you very much.
from camera.maui.
Hi Jason
I know ZXing.net.maui, but this plugging has ZXing.Net integrated too and maybe you don't need the first. You can detect barcodes with the CameraView using the event "BarcodeDetected" and setting the property "BarCodeDetectionEnabled" to True (if you set it to False, the barcode detection stops) and "BarCodeOptions" property.
For image manipulation I recomend you to use the method "SaveSnapShot", It saves the image to a file and then you can read the bytes from the file and convert it to Base64 (wihtout ImageSource).
If you wanna use your code, I think that you have to set the MemoryStream Position to 0 before use it in the ImageSource:
var imageBytes = Convert.FromBase64String(weighRecord.Picture);
using MemoryStream memoryStream = new(imageBytes);
memoryStream.Position = 0;
contaminationPicture.Source = ImageSource.FromStream(() => memoryStream);
from camera.maui.
Hi Hector,
I fixed the image issue. It’s caused by “using” statement.
I am going to replace ZXing.net.maui with your Camera.maui plugin.
Some suggestions to Camera.maui plugin. Is it possible to make it compatible to MVVM pattern? Instead of calling function directly from the control, could you make some bindable property or event, which can be converted to command easily?
Thanks for the help once again.
You can close the issue now.
Jason
from camera.maui.
Hi Jason,
Your suggestion is welcomed. I added bindable properties for the snapshotting and barcode detection.
from camera.maui.
Related Issues (20)
- The recorded video was not saved locally
- Barcode not shown up HOT 10
- Activating the flash when starting a camera in crashes on Android
- Camera vibrate
- Overlay / Region-of-interest
- [Question] Can this package be used for a .net 8 iOS app (not a MAUI app)?
- Slow Barcode Reading HOT 2
- Upside down
- Library crashes and becomes unresponsive while using AutoSnapShot and Barcode reading on IOS
- TorchEnabled not working on Android
- Can't focus if subject is too near from the camera (for iPhone14 Pro and above models) HOT 3
- camera always rotates HOT 1
- How to use library for making photo automatically HOT 1
- Poor resolution HOT 1
- can't scan Ean13 format
- Android only NullReferenceException on double StartCameraAsync HOT 2
- version 1.5.1 does not work on ios HOT 3
- StartRecordingAsync helds and send acces error in net maui ios
- `NullReferenceException` inside `cameraView.TakePhotoAsync` HOT 3
- Resolution doesnt change
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from camera.maui.