-
Notifications
You must be signed in to change notification settings - Fork 705
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
Camera Focus Issue #395
Comments
Hello, I'm not developper of this great project but I've a little bit information With the last version 2.1.44, no focus, the preview is blurry After flash activated and wait 3-5 seconds, focus is triggered and the preview is OK But it's only after flashlight using, it's a bug Best regards |
The auto focus code was changed in this release. I suspect some devices don't do a good job of implementing proper auto focus. You can of course manually invoke AutoFocus ()... I will test on more of my devices and see if I can find one that has these issues.... |
Redth, I did make a call to auto focus but that did not seem to help. However, I may not be using the method properly. We have two scenarios in our Xamarin Forms/PCL app: (1) we are using continuous scanning with an overlay, and (2) we acquire a single scan and immediately return. In either scenario, when should the auto focus call be made? I have noticed that when the camera is within range of a valid barcode, it will focus enough to capture the barcode. If the barcode is not in range, it is hit or miss if the camera focuses (sometimes it works.) However, if I hit the back button and then go back in, it seems to focus every time. Not sure if that helps. |
Thanks for the answer I just add this code before start scan to resolve this issue |
So, previous to 2.1.44 auto focus was done by calling I'm going to to dig into the code a bit more and see if i can detect when a camera doesn't support autofocus and revert back to the 'old' way of calling AutoFocus on a timer. First I need to go through my devices and see if I can find one that doesn't support autofocusing properly... |
I'm experiencing exactly what moflaherty and edynamic90 have already described. I'm testing with a Samsung Galaxy S3 (SGH i747) running 4.4 and a HTC One running 5.0.2. I have a client with a Nexus 5x running 6.0.2 who reported the same issue. All of these devices support autofocus. I improved the situation by modifying the call to AutoFocus within the SetupCamera method in ZXingSurfaceView. I wrapped in a timer with a delay of 800 ms. |
Moto G2 and G3 also don't auto focus |
LG G4 the same problem |
After update to last stable version (2.1.47) auto-focus on continous scanning not working. Using .AutoFocus() method is not good idea. Tested on Samsung SM-A510F (Android API 23). Previous versions (before 2.1) was working very well |
J1 Mini is also facing the same problem. |
For anyone using Xamarin Forms the following works really well |
Hi, any news about this problem? The timer solution for trigger autofocus has some problems related to different threads. I also have to call Stop (or cancel the tcs) in UI thread? |
I can confirm that in version (2.1.47) auto-focus on continuous scanning is not working. Using the .AutoFocus on a timer seems to make a minor improvement. Is it suggested to use a version prior to 2.1 until the issue is fixed? |
I can confirm this issue on Samsung J5 Prime, Sometimes preview autofocus works but when user tap the screen it blurred. |
I can confirm this on nexus 5x. Any idea what code introduced this problem? Update: seems to be working fine on master. The problem I had was in 2.1 xamarin component. Update 2: It's also working with latest nuget package (2.3.2). It seems that my mistake was to use the outdated xamarin component, still on version 2.1. The focus mode set on nexus 5x is FocusModeContinuousPicture (on the CameraController.ApplyCameraSettings method). |
I'm also having auto focus issues on Samsung Galaxy Xcover 3 (G389F) using Xamarin Forms 2.3.4.270 and ZXing.Net.Mobile 2.3.2. As some people already suggested, adding a timer that calls AutoFocus periodically helps somewhat. On the debub console I keep getting these messages: (I didn't have any issues on Sony Xperia Z2, Samsung Galaxy S5 and Moto G5.) Update: I managed to fix the auto focus issue for the above mentioned phone. I've been doing some digging in ZXing.Net.Mobile.Android to see how the camera is set up and noticed that it sets the preview FPS in CameraController.cs using the following logic: // This will make sure we select a range with the lowest minimum FPS
// and maximum FPS which still has the lowest minimum
// This should help maximize performance / support for hardware
foreach (var fpsRange in parameters.SupportedPreviewFpsRange)
{
if (fpsRange[0] <= selectedFps[0] && fpsRange[1] > selectedFps[1])
selectedFps = fpsRange;
}
parameters.SetPreviewFpsRange(selectedFps[0], selectedFps[1]); This logic was selecting the lowest FPS rate supported by the phone: Setting the FPS explicitly to the maximum supported value (30fps) seems to be the solution for me: Now the camera preview on the phone is much more responsive (before it was sluggish) and the auto focus works like a charm. I do believe that the logic for selecting the FPS rate is flawed and should not be applied to every phone automatically. Alternatively it would be nice to have to ability to overwrite this setting through the MobileBarcodeScanningOptions, just like you can for the resolution. Update 2: foreach (var fpsRange in parameters.SupportedPreviewFpsRange)
{
if (fpsRange[1] > selectedFps[1] || fpsRange[1] == selectedFps[1] && fpsRange[0] < selectedFps[0])
selectedFps = fpsRange;
}
parameters.SetPreviewFpsRange(selectedFps[0], selectedFps[1]); |
@Redth now that you're working on 3.0+ would you consider re-lookong at this? The issues with the preview framerate being arbitrarily set to maximum on some devices is the reason my team had to abandon this projects stable releases a few years back since it never got solved - would love to move back to using your 3.0+ versions if this is resolved! :) |
Yes! |
@Strifex i'm going to call this one fixed. If you look in the source, I did actually merge or incorporate better logic around this some time ago, so it's part of the 3.0 beta releases already: https://github.com/Redth/ZXing.Net.Mobile/blob/master/ZXing.Net.Mobile/Android/CameraAccess/CameraController.android.cs#L245-L253 I just stepped through it again, and given my phone which supports: |
Unfortunately, a bug with autofocus was not fixed in version 3.0.1 I use ZXing.Net.Mobile.Forms v.3.0.1 II tried to use a workaround, but autofocus steel does not work. ZXingScannerView zxing; |
Hi! We updated to 2.1.13 in our Xamarin Forms/PCL project and now the camera does not auto focus. Sometimes exiting the scan form and going back in causes it to focus properly. We did not experience this issue with 2.0.4.46. We have tested this on a few devices--mine is a Moto X Gen 2. Any idea what is going on? I can go back to the older version, but that also fixes other issues that caused us grief. Thanks!
The text was updated successfully, but these errors were encountered: