Giter Site home page Giter Site logo

camera.maui's People

Contributors

ddhschmidt avatar expecho avatar hjam40 avatar jfversluis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

camera.maui's Issues

Flip cameras not working

Hi

I'm trying to flip (change) cameras on iOS device but it does not work.

The front camera works fine, but when I click the button to switch to back camera, it stop the camera stream.
I also tried start with the back camera, it works, but when I hit the button to switch to front camera it also stops the stream.

Here is the code:

    private void CameraView_CamerasLoaded(object sender, EventArgs e)
    {
        StartCamera(CameraPosition.Front);

    }

    private async void StartCamera(CameraPosition position)
    {
        await MainThread.InvokeOnMainThreadAsync(async () =>
        {
            await cameraView.StopCameraAsync();
            cameraView.Camera = null;

            cameraView.Camera = cameraView.Cameras.Where(f => f.Position == position).First();
            cameraView.MirroredImage = true;

            await cameraView.StartCameraAsync();
            canvas.InvalidateSurface();
        });
    }

    void CameraView_FlipCamera(System.Object sender, System.EventArgs e)
    {
        CameraPosition position = cameraView.Camera.Position == CameraPosition.Front ? CameraPosition.Back : CameraPosition.Front;
        StartCamera(position);
    }

and xaml:

    <cv:CameraView x:Name="cameraView"
                       Grid.RowSpan="4"
                        CamerasLoaded="CameraView_CamerasLoaded"
                                />


                   <Button
                   Grid.Row="0"
                    Grid.Column="2"
                    Text="{Binding Source={x:Static helpers:MaterialDesignIconFonts.CameraFlip}}"
                    Style="{StaticResource TreinifyIconLabelStyle}"
                    Clicked="CameraView_FlipCamera"
                    />

"Access Error"

Hi, Thanks for the project. It's a good choice before .NET Maui community toolkit add the cameraview.
I tried it on my Samsung tablet, and got "access error" after calling "StartCameraAsync".
What is the reason of "access error"?

Problem with new build

After upgrading to 1.4 I am now getting the following with testing the cameraview on my android device. I have removed all my code so that the only think is the reference to the cameraview in the xaml .

Here is the error

{System.NullReferenceException: Object reference not set to an instance of an object.
at Camera.MAUI.Platforms.Android.MauiCameraView.InitDevices()
at Camera.MAUI.Platforms.Android.MauiCameraView..ctor(Context context, CameraView cameraView)
at Camera.MAUI.CameraViewHandler.CreatePlatformView()
at Microsoft.Maui.Handlers.ViewHandler`2[[Camera.MAUI.CameraView, Camera.MAUI, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null],[Camera.MAUI.Platforms.Android.MauiCameraView, Camera.MAUI, Version=1.4.0.0, Culture=neutral, PublicKeyToken=null]].OnCreatePlatformView() in D:\a_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 72

Video Resolution

Hello,

Is there a way to make a lower resolution video using cameraView.StartRecordingAsync?

Thanks for a great control!

Daniel

PopAsync in modal stack on Windows crashes

Using CameraView in a modal stack I found that calling Navigation.PopAsync triggers a crash on Windows at random times. The attached repro illustrates this.

From the main window:

  1. Tap the Open Modal button, a modal window/page appears
  2. Tap the Go Forward button, a new page with the CameraView is pushed on the modal stack.
  3. Tap the Go Back button. Repeat steps 2 and 3 until the crash happens.

Crash info:

Exception thrown: 'System.Runtime.InteropServices.COMException' in System.Private.CoreLib.dll
An exception of type 'System.Runtime.InteropServices.COMException' occurred in System.Private.CoreLib.dll but was not handled in user code
Error HRESULT E_FAIL has been returned from a call to a COM component.

This is occurring with the current published nuget, version 1.3.5. The attached repro solution was created new from template today with the latest Visual Studio and MAUI app templates.

CameraMauiBugWindows-PopAsyncCrash.zip

Setting zoom factor on Android does not make a difference

Hi

We have tried various camera settings, including the zoom factor, which seems to have no effect on the view port on Android (works fine on iOS).

cameraView.ZoomFactor = 2.5f;

We have tested using a Google Pixel 7 Pro using version 1.3.1. Any thoughts?

No proview / no snapshot

Hi

I installed folowing the documentation but I get no preview in the CameraView control.
GetSnapShot() return a null ImageSource.

Any idea ?

Providing access to idividual frames.

For now, it seems the only way to get an image using this plugin is by doing something like cameraView.GetSnapShot(Camera.MAUI.ImageFormat.JPEG); or am I wrong?

The built-in barcode/QR detection uses the FrameReader_FrameArrived event as seen here on the Windows platform (haven't looked at the other platform implementations). How about making this event public so consumers can subscribe and process the received frames by, for example, ML algorithms, other QR/Barcode libs or whatever one needs?

If it fits your purpose I am more than willing to try to come up with an implementation, although testing on an IOS device would be hard for me as I don't have one.

cameraView.TakePhotoAsync() return null on Android, while working normal on Windows

When I try to set cv:CameraView's IsVisible="False", or WidthRequest and HeightRequest to 0 cameraView.TakePhotoAsync(); returnrs null when trying to run the program on Android, while on Windows it works perfectly fine. Also WidthRequest and HeightRequest of cv:CameraView affects the quality of the result from cameraView.TakePhotoAsync() on Android, when again, on Windows it works perfectly fine.

Here are the snippets of code from MainPage.xaml.cs and MainPage.xaml

var stream = await cameraView.TakePhotoAsync();
  if (stream != null)
    {
        var result = ImageSource.FromStream(() => stream);
        displayImage.Source = result;
    }
<cv:CameraView
    x:Name = "cameraView"
    IsVisible="True"
    WidthRequest="100"
    HeightRequest="20"
/>

<Image
    x:Name="displayImage"
    Source="dotnet_bot.png"
    IsVisible="True"
    Aspect="AspectFit"
/>

My devices`

  • Windows 11 PC
  • Android 11 on Sasmsung Galaxy S10
  • Emulated Android 9 on Pixel 5

Typo in README

There's a slight typo in the README under "Using CameraView":

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

no preview

work fine but with front camera , after switch to back camera have no preview .
I use provided test project in GitHub with no change , just start it .
test phone is honor 8A android 9

also this error showed in output when staring back camera [GLConsumer] [SurfaceTexture-0-20313-0] bindTextureImage: error binding external image: 0x502

Access raw camera feed

As Gerald Versluis in his Video stated: it would be interesting if we could get access to the raw camera feed with this library. Then it would be possible to create augmented reality apps with .NET MAUI.

Second (And only second!) photo after first run always fails. [Warning: Unable to load image stream.]

We have exactly the same issue with an app we are working on, so I figured lets see how others have got around it!
I just pull the repo and run it, click smile, and second click fails with log below:

[0:] Microsoft.Maui.StreamImageSourceService: Warning: Unable to load image stream.

Android.Util.AndroidRuntimeException: Only the original thread that created a view hierarchy can touch its views.
at Java.Interop.JniEnvironment.StaticMethods.CallStaticVoidMethod(JniObjectReference type, JniMethodInfo method, JniArgumentValue* args) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/obj/Release/net7.0/JniEnvironment.g.cs:line 13250
at Java.Interop.JniPeerMembers.JniStaticMethods.InvokeVoidMethod(String encodedMember, JniArgumentValue* parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniStaticMethods.cs:line 97
at Microsoft.Maui.PlatformInterop.LoadImageFromStream(ImageView imageView, Stream inputStream, IImageLoaderCallback callback) in D:\a_work\1\s\src\Core\src\obj\Release
et7.0-android\generated\src\Microsoft.Maui.PlatformInterop.cs:line 443
at Microsoft.Maui.StreamImageSourceService.LoadDrawableAsync(IImageSource imageSource, ImageView imageView, CancellationToken cancellationToken) in D:\a_work\1\s\src\Core\src\ImageSources\StreamImageSourceService\StreamImageSourceService.Android.cs:line 28
--- End of managed Android.Util.AndroidRuntimeException stack trace ---
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8798)
at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1606)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at androidx.drawerlayout.widget.DrawerLayout.requestLayout(DrawerLayout.java:1353)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at androidx.recyclerview.widget.RecyclerView.requestLayout(RecyclerView.java:4586)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at androidx.core.widget.NestedScrollView.requestLayout(NestedScrollView.java:2075)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.widget.ImageView.setImageDrawable(ImageView.java:597)
at androidx.appcompat.widget.AppCompatImageView.setImageDrawable(AppCompatImageView.java:112)
at com.microsoft.maui.glide.MauiCustomViewTarget.onResourceCleared(MauiCustomViewTarget.java:30)
at com.bumptech.glide.request.target.CustomViewTarget.onLoadCleared(CustomViewTarget.java:210)
at com.bumptech.glide.request.SingleRequest.clear(SingleRequest.java:337)
at com.bumptech.glide.request.ErrorRequestCoordinator.clear(ErrorRequestCoordinator.java:48)
at com.bumptech.glide.manager.RequestTracker.clearAndRemove(RequestTracker.java:70)
at com.bumptech.glide.RequestManager.untrack(RequestManager.java:660)
at com.bumptech.glide.RequestManager.untrackOrDelegate(RequestManager.java:628)
at com.bumptech.glide.RequestManager.clear(RequestManager.java:624)
at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:811)
at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:780)
at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:771)
at com.microsoft.maui.PlatformInterop.prepare(PlatformInterop.java:229)
at com.microsoft.maui.PlatformInterop.loadInto(PlatformInterop.java:234)
at com.microsoft.maui.PlatformInterop.loadImageFromStream(PlatformInterop.java:265)

--- End of managed Android.Util.AndroidRuntimeException stack trace ---
android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8798)
at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1606)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at androidx.drawerlayout.widget.DrawerLayout.requestLayout(DrawerLayout.java:1353)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at androidx.recyclerview.widget.RecyclerView.requestLayout(RecyclerView.java:4586)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at androidx.core.widget.NestedScrollView.requestLayout(NestedScrollView.java:2075)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.view.View.requestLayout(View.java:25390)
at android.widget.ImageView.setImageDrawable(ImageView.java:597)
at androidx.appcompat.widget.AppCompatImageView.setImageDrawable(AppCompatImageView.java:112)
at com.microsoft.maui.glide.MauiCustomViewTarget.onResourceCleared(MauiCustomViewTarget.java:30)
at com.bumptech.glide.request.target.CustomViewTarget.onLoadCleared(CustomViewTarget.java:210)
at com.bumptech.glide.request.SingleRequest.clear(SingleRequest.java:337)
at com.bumptech.glide.request.ErrorRequestCoordinator.clear(ErrorRequestCoordinator.java:48)
at com.bumptech.glide.manager.RequestTracker.clearAndRemove(RequestTracker.java:70)
at com.bumptech.glide.RequestManager.untrack(RequestManager.java:660)
at com.bumptech.glide.RequestManager.untrackOrDelegate(RequestManager.java:628)
at com.bumptech.glide.RequestManager.clear(RequestManager.java:624)
at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:811)
at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:780)
at com.bumptech.glide.RequestBuilder.into(RequestBuilder.java:771)
at com.microsoft.maui.PlatformInterop.prepare(PlatformInterop.java:229)
at com.microsoft.maui.PlatformInterop.loadInto(PlatformInterop.java:234)
at com.microsoft.maui.PlatformInterop.loadImageFromStream(PlatformInterop.java:265)

Logo integration in QR Code

Concerning identification with special services or products it would be usefull that it is pssoible to integrate a logo.

attempting to exceed the max dequeued buffer count

When using this library my output log is flooded with
"attempting to exceed the max dequeued buffer count" warnings.
Is this something I should be worried about or can safely be ignored?

image

So far my code is very simple, more or less the same code as the bar code example.

image

image

Permissions Issue: Android 9 and 13

I've run into an issue with permissions in Android on both phones I have for testing.

Even with the AndroidManifest.xml updated as per the documentation, the app doesn't prompt for permissions on start.
I have to specifically check if permission has been granted:
status = await Permissions.CheckStatusAsync<Permissions.Camera>();

When this returns as denied, I can then call:
status = await Permissions.RequestAsync<Permissions.Camera>();

Now, that works the first time the app is run, with no permissions granted. However, once I grant the app permission, the camera will not work on subsequent runs. I have to go into settings and revoke the permissions so it can prompt again and the camera will work again.

Any clues as to why this might be happening?

TakePhotoAsync crashing whole app on windows

While invoking TakePhotoAsync() function whole app crashes, I have no idea why because code is same as in example, also project was configured same as shown in readme

Code:

private async void ScanButtonOnClicked(object sender, EventArgs e)
{
	var stream = await CameraView.TakePhotoAsync();
	if (stream == null) return;
		
	var result = ImageSource.FromStream(() => stream);
	ImagePreview.Source = result;
}

Error:

System.ArgumentException: Value does not fall within the expected range.
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
   at WinRT.ExceptionHelpers.ThrowExceptionForHR(Int32 hr)
   at ABI.Windows.Graphics.Imaging.ISoftwareBitmapStaticsMethods.Convert(IObjectReference _obj, SoftwareBitmap source, BitmapPixelFormat format, BitmapAlphaMode alpha)
   at Windows.Graphics.Imaging.SoftwareBitmap.Convert(SoftwareBitmap source, BitmapPixelFormat format, BitmapAlphaMode alpha)
   at Camera.MAUI.Platforms.Windows.MauiCameraView.TakePhotoAsync(ImageFormat imageFormat)
   at Camera.MAUI.CameraView.TakePhotoAsync(ImageFormat imageFormat)
   at Animatron.MainPage.ScanButton_OnClicked(Object sender, EventArgs e)
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Microsoft.UI.Dispatching.DispatcherQueueSynchronizationContext.<>c__DisplayClass2_0.<Post>b__0()

Barcode Reader keeps working until BarCodeDetectionEnabled is set to false

Hi Hector,

I tried barcode reader function today. It's very good.
Just one issue.
After I turn on BarCodeDetectionEnabled, the engine keeps working.
As I turn off BarCodeDetectionEnabled inside the event handler, usually my code receives multiple barcode detected events.
Is there any way to detect only once?

Thank you very much.

Jason

iPhone 14 Pro Focus Issue

Using iOS 16.4, camera view loads along with barcode detection. However the camera view will not focus on a barcode in order to detect it. No exceptions thrown as in latest ZXing library.

No Windows Preview nor Windows Barcode Detection

Using Gerald Versiuis' two recent Camera.View sample projects, as discussed in his matching YouTube videos, I am unable to see a CameraView preview in either when using a Windows 11 Webcam and running VS 2022 Enterprise Preview. (I had to make minor changes to his csprog files as neither contained a properly-formatted ApplicationIdGuid and an assembly neutral language, both required for Windows.) However, in the earlier project for image capture, an image can be captured from that webcam and properly displayed beneath where the preview should appear. In the latter project for barcode scanning, the same webcam does get started (still no preview), but no barcode detection occurs. Same project works as expected on an actual Android device.

AutoFocus?

The lack of auto focus keeps us from using this. Does the ZXing control have an AutoFocus method? If so, can you expose it in this control so I can call it periodically? If this is not possible, is there another way to force a focus adjustment?

Vertical and Horizontal angles

The camera properties doesn't have The Horizontal and Vertical angles:
for android the old Camera object has:

cameraObject.GetParameters().HorizontalViewAngle
cameraObject.GetParameters().VerticalViewAngle

where cameraObject is the Android.Hardware.Camera.

for iOS the field of view needs to be calculated so:

private void ComputeFOVfromCameraFormat()
        {
            nfloat aspectRatio = previewLayer.Bounds.Size.Width / previewLayer.Bounds.Size.Height;
            if (aspectRatio > 1.0) aspectRatio = 1.0f / aspectRatio;

            AVCaptureDeviceFormat activeFormat = this._captureDevice.ActiveFormat;

            CoreMedia.CMFormatDescription description = activeFormat.FormatDescription;
            CoreMedia.CMVideoDimensions dimensions = activeFormat.HighResolutionStillImageDimensions;

            nfloat activeFOV = 2.0f * (float)(Math.Atan(Math.Tan((0.5 * activeFormat.VideoFieldOfView).ToRadians()) / this._captureDevice.VideoZoomFactor) / (Math.PI / 180));

            nfloat aspectWidth = (nfloat)dimensions.Height / aspectRatio;
            nfloat aspectHeight = (nfloat)dimensions.Width * aspectRatio;

            if (this.videoGravity == AVLayerVideoGravity.ResizeAspectFill)
            {
                nfloat aspectFOV;

                if (aspectWidth < dimensions.Width)
                {

                    aspectFOV = (nfloat)(2.0 * Math.Atan(aspectWidth / (nfloat)dimensions.Width * Math.Tan((0.5 * activeFOV).ToRadians())) / (Math.PI/180));

                }
                else if (aspectHeight < dimensions.Height)
                {

                    aspectFOV = activeFOV;

                }
                else
                {

                    aspectFOV = activeFOV;
                }

                _fieldOfViewPortrait = aspectFOV;
                _fieldOfViewLandscape = (nfloat)(2.0 * Math.Atan(Math.Tan((0.5 * aspectFOV).ToRadians()) * aspectRatio) / (Math.PI/180));
            }
            else if (this.videoGravity == AVLayerVideoGravity.ResizeAspect)
            {
                nfloat aspectFOV;

                if (aspectHeight > dimensions.Height)
                {

                    // Left and right bars added (in portrait)
                    //
                    aspectFOV = activeFOV;

                }
                else if (aspectWidth > dimensions.Width)
                {

                    // Top and bottom bars added (in portrait)
                    //
                    aspectFOV = (nfloat)(2.0 * Math.Atan(aspectWidth / (nfloat)dimensions.Width * Math.Tan((0.5 * activeFOV ).ToRadians())) / (Math.PI/180));
                }
                else
                {

                    // Matching aspect ratio -- no bars added
                    //
                    aspectFOV = activeFOV;
                }

                _fieldOfViewPortrait = aspectFOV;
                _fieldOfViewLandscape = (nfloat)(2.0 * Math.Atan(Math.Tan((0.5 * aspectFOV ).ToRadians()) * aspectRatio) / (Math.PI/180));
            }
        }

These properties very useful to detect if an object in the space (x, y, z) is within the camera view range.
so if you add these properties will be great.

getMicrophones error on older Androids

example on Android 5
Java.Lang.NoSuchMethodError
Message=no non-static method "Landroid/media/AudioManager;.getMicrophones()Ljava/util/List;"

0x12 in Android.Media.AudioManager.get_Microphones at /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/net7.0/android-33/mcw/Android.Media.AudioManager.cs:1537,6
0x177 in Camera.MAUI.Platforms.Android.MauiCameraView.InitDevices C#

Looks like it just needs an API check similar to the following

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { List<MicrophoneInfo> mics = am.getMicrophones(); ... } else { AudioDeviceInfo[] deviceInfo = am.getDevices(AudioManager.GET_DEVICES_INPUTS); ... }

in Android/MauiCameraView.cs : InitDevices() : line 92

several examples online search for:
no non-static method "Landroid/media/AudioManager;.getMicrophones()Ljava/util/List;"

Issues working with Blazor MAUI Projects.

Ive been trying to use you're Camera.MAUI view in my Blazor MAUI project, however I can't seem to get it to work and all the examples here use XAML.

Ive followed the examples best ive can and making adjustments for Blazor. Which includes adding .UseMauiCameraView to "Mauiprogram.cs", giving the Android device Camera permissions and adding xmlns:cv="clr-namespace:Camera.MAUI;assembly=Camera.MAUI" to MainPage.xaml

However, the bit that i get an error on is: cameraView.Camera = cameraView.Cameras.First(); which is part of the function ran when the button is pressed to display the camera.

Where the issue is that cameraView.Cameras is never set, which is caused by the CameraViewHandler never being run and since CameraViewHandler is Protected i'm not able to call it myself.

Would you know how to address this?

Black screen with an Android device (s21 ultra)

Nice project (works fine under windows by following the mini tuto on the github page), but I have a black screen when I launch the app with an Android device (Samsung galaxy s21 Ultra exynos version). Strange thing, when my app switches to thumbnail (by pressing the home button on my phone), for one frame I see the camera stream, before everything goes black again.

EDIT:
A small track to understand the bug; on this line the value of Width and Height is 0
previewView.LayoutParameters = new LayoutParams { Width = Width, Height = Height };
If I enter arbitrary positive values here, I get my control displayed.

Slow QR code processing on Android due to multiple QR decoding tasks running simultaneously

I've noticed that the decoding of QR codes appears to run on ThreadPool tasks based on a timer without any consideration for existing tasks. I can sometimes see upwards of 10 threads running simultaneously depending on how I set the frame rate. This leads to a couple of issues for me:

  1. The app slows to a crawl and the camera begins to stutter as more tasks are started. This is especially noticeable on older smartphones.
  2. Once a barcode is detected the user is directed to a page that asks for more information. However, they can hit the back button and go back to the QR scanning page. Sometimes, one of the still-running threads will finish and cause the BarcodeDetected event to fire even though there is no QR code in front of the camera.

camera do not work in window

I want to display my webcam on window, and camera on android.
In android that work but in window no why ?

My code:

`public MainPage()
{
InitializeComponent();
foreach (var i in CameraView.Cameras)
{
Console.WriteLine(i.Name);
}
}

private void CameraView_CamerasLoaded(object sender, EventArgs e)
{
    if (CameraView.NumCamerasDetected <= 0) return;
    
    if (CameraView.NumMicrophonesDetected > 0) CameraView.Microphone = CameraView.Microphones.First();
    CameraView.Camera = CameraView.Cameras.First();
        
    MainThread.BeginInvokeOnMainThread(async () =>
    {
        await CameraView.StartCameraAsync();
    });
}`

my Package.appxmanifest:
<Capabilities> <rescap:Capability Name="runFullTrust" /> <DeviceCapability Name="webcam"/> <DeviceCapability Name="microphone"/> </Capabilities>

When trying to open CameraAsync: System.NullReferenceException: 'Object reference not set to an instance of an object.'

public async Task CameraLoadAsync()
        {
            if (mainView.camera.Cameras.Count > 0)
            {
                mainView.camera.Camera = mainView.camera.Cameras.First();

                if (mainView.camera ==  null) return;

                MainThread.BeginInvokeOnMainThread(async () =>
                {
                    await mainView.camera.StopCameraAsync();
                    await mainView.camera.StartCameraAsync();
                });
            }
        }

When trying to StartCameraAsync it gives this error: System.NullReferenceException: 'Object reference not set to an instance of an object.'
I checked but nothing is null neither the camera or cameraView

Saved .Jpg files are limited resolution

The saved files using the stream returned from CameraView.TakePhotoAsync();
Are limited to 788x1054 on all the cameras listed on my Samsung S22 Ultra. (front and back)

Can we get an image with the full resolution of the selected camera?

Using version 1.3.5

I want to record multiple split videos

My code:

while (flag)
{
    var file = Path.Combine(FileSystem.Current.CacheDirectory, $"file_{DateTime.Now:hhmmss}.mp4");
    var result = await cameraView.StartRecordingAsync(file);
    await Task.Delay(10000);
    result = await cameraView.StopRecordingAsync();
    var f = new FileInfo(file);
    Console.WriteLine("file length: " + f.Length);
    await Task.Delay(200);  //if remove the line it will throw exception
}

But every mp4 file loses 1-2 seconds.
Could you improve it?
example:
StartRecordingAsync(TimeSpan span, Action callback)
StartRecordingToDirectoryAsync(string directory, TimeSpan span)

Suggestion:
Resolution ratio allows configuration.
mediaRecorder.SetVideoSize(540, 320)

Forgive me for my poor english.
Thanks

Access Error on Android 8 (AudioManager getMicrophones())

On a device with Android 8 (API Level 26) the app crashes with the method "CamerasLoaded or MicrophonesLoaded" with the error message:
"**Java.Lang.NoSuchMethodError:** 'no non-static method "Landroid/media/AudioManager;.getMicrophones()Ljava/util/List;"'"
The CamerView works on an emulator with Android 13.

Later I saw that there was already a post about this. I then tried to use the code from the README:

private void camerView_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 () =>
            {
                await cameraView.StopCameraAsync();
                var result = await cameraView.StartCameraAsync();
                lblCameraResult.Text = "Camera: " + result.ToString();
            });
        }
    }

Then it doesn't crash, but you always get an AccessError as a result. Can this be fixed somehow?

android 8 noSuchMethodError

I have also comment out the following lines but getMicrophones() method is not found error thrown.
tested on emulator and test phone.

//if (cameraView.NumMicrophonesDetected > 0)
// cameraView.Microphone = cameraView.Microphones.First();

exception:
image

call stack:
image

thank you.

CameraView takes over iOS popup

When using the Popups from the Maui community toolkit on iOS, the cameraView takes over all elements, making it impossible to use buttons.

Steps to reproduce:

  1. Create new Maui Blazor app
  2. Install Camera.MAUI en Communitytoolkit.Maui
  3. Create a Community toolkit popup and attach a popup using the following method (https://youtu.be/2dllz4NZC0I?t=918, 3rd option)
  4. Add a button to the popup with the function Close()
  5. Run the app
RPReplay_Final1686129106.1.mp4

On android this will work perfectly fine, but when deploying on iOS the button can not be pressed. When the cameraView is removed, the button can be clicked. It is also possible to click on the background to close the popup, which isnt possible when the CameraView is on the popup.
The code for this problem can also be found here (https://github.com/Jensevent/PopUpTest). In this app myPopup.xaml is my Community toolkit popup.
I am trying to build to an Iphone 7, working from a mac mini with Ventura 13.4. If you need anything more, just ask.

poor image quality

Camera view quality is very bad & blurry therefore barcode detection not working properly. How to increase image qualty or resolution?

Capture a full-resolution image from camera

Hi, thanks for your project! It really help me lot. 😊
Is it possible to capture a full resolution image from camera?

The "SaveSnapShot()" method gives me an image that was way too small on my phone (iPhone 12 Pro, snapshot was 320px x 640px, 512 KB)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.