Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds scanner recognition in some android devices #180

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sbricchi
Copy link

This change allows to detect codes in some Android device models that seems to report a different image format to the expected by this plugin.
You can find the solution and the problem explanation by https://github.com/gyaccuzzi at this issue:
#107

It's proven to add image recognition for these devices:

Motorola G82
Motorola G30
Motorola G5 (oldie)
Samsung A23

I can guess that it fixes many other models .
I'm not sure if changing the image scanning format could create any other kind of performance issues.

@Eskissimo
Copy link

Hi,

I suggest this additional code in order to get a good detection :

1- Add a constructor to handle orientation change :

    public CameraManager()
    {
        DeviceDisplay.MainDisplayInfoChanged += DeviceDisplay_MainDisplayInfoChanged;
    }

2- Update camera on orientation change :

    private void DeviceDisplay_MainDisplayInfoChanged(object sender, DisplayInfoChangedEventArgs e)
    {
        if (cameraPreview != null) UpdateCamera();
    }

3- Unregister event in Dispose :

    public void Dispose()
    {
        DeviceDisplay.MainDisplayInfoChanged -= DeviceDisplay_MainDisplayInfoChanged;

        cameraExecutor?.Shutdown();
        cameraExecutor?.Dispose();
    }

4- Configure camera preview with the same settings of the image analyzer :

            cameraPreview = new AndroidX.Camera.Core.Preview.Builder()
                .SetDefaultResolution(new Android.Util.Size(640, 480))
                .SetIsRgba8888SurfaceRequired(true)
                .Build();
            cameraPreview.SetSurfaceProvider(previewView.SurfaceProvider);

Regards.

Jon2G added a commit to Jon2G/ZXing.Net.Maui that referenced this pull request May 24, 2024
@hassanraf
Copy link

@sbricchi @Eskissimo Any idea when these changes will be merged into master?
Thanks

@Jon2G
Copy link

Jon2G commented Jun 21, 2024

@Redth Can you take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants