Redth / ZXing.Net.Mobile

Barcode Scanner for Xamarin.iOS, Xamarin.Android, UWP and Tizen
MIT License
1.07k stars 700 forks source link

ZXingScannerView shows camera stream rotated by 90 degrees in some devices. How can I fix rotation? #1068

Open AthanasiosKampylis opened 1 year ago

AthanasiosKampylis commented 1 year ago

I use ZXingScannerView to scan a QR Code, but althought on many devices I have tested the camera works fine (both Portrait & Landscape), in one specific device the Video from camera stream is always rotated 90 degrees. I tried set "TryHarder" property to true or false, but nothing changes.

Here is a sample code. In code behind I initialize ZXingScannerView: private void InitializeBarcodeCameraView { if (_viewModel != null) { _scanView = new ZXingScannerView() { IsScanning = true, IsAnalyzing = true, WidthRequest = 300, IsVisible = true, Options = _viewModel.UseBackCamera, }; _scanView.OnScanResult += Camera_OnScanResult; } }

and at ViewModel I also initialize UseBackCamera property as follows:

UseBackCamera = new MobileBarcodeScanningOptions() { UseFrontCameraIfAvailable = false, };

where, public MobileBarcodeScanningOptions UseBackCamera { get { return _useBackCamera; } set { _useBackCamera = value; RaisePropertyChanged(nameof(UseBackCamera)); } }

I tried in code behind to set "Rotation" property for example 90 degrees with no result, as the only thing that rotates is ZXingScannerView and not the camera stream video itself.

Is there any "best practice" to set for example a property to force the rotation of video stream (in degrees) for the problematic specific device, without configuring the native library (I need to use the nuget package instead)?

pachecosoftware commented 1 month ago

We are also seeing this same issue on iOS devices. Would welcome a suggestion/fix for the issue.