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

Iphone 4 focus problem #103

Open
Steefkroon opened this issue Mar 31, 2014 · 12 comments
Open

Iphone 4 focus problem #103

Steefkroon opened this issue Mar 31, 2014 · 12 comments

Comments

@Steefkroon
Copy link

I seem to have a problem with the barcode scanner plugin. It seems that when starting a scan it takes the initial focus from the camera, but when you change position the camera doesnt refocus not even if I tap on the screen. What can I do.

@dirtyrobinson
Copy link

I am also dealing with this issue except my app doesn't do an initial focus. It's just blurry resolution regardless of camera/barcode distance and position.

iPhone 4s, fully updated iOS, phonegap app built using Adobe's build.phonegap.com

@benlarkins
Copy link

+1 to this. iPhone 4 running iOS 7.1 and the barcode scanner won't refocus. If you launch the barcode scanner with the phone at the right distance from the barcode then it focuses and scans. However if the barcode is not in focus when the scanner is launched the camera will never focus on it.

@ksennoun
Copy link

I'm facing this issue too. Have you found a workaround or quick fix?

@ksennoun
Copy link

ksennoun commented Jun 2, 2014

I was able to state that the problem only appears on iPhones 4 and 7.0+ iOS. Are we all affected by this issue? If someone came up with a fix, even native, please share your solutions.

@dirtyrobinson
Copy link

I have tested this plugin on a few iOS devices running iOS 7+ and the problem lies on all of them but the problem is not limited to this plugin. I have also tried several apps and other plugins that use the zxing barcode scanner "framework" and none of them allowed the camera to refocus. I'm not an expert on this stuff so I hope this comment makes sense. If it does make sense, I have no idea what the solution would be. Right now, my solution is to release my app for Android only but I really need something working on iOS.

@ksennoun
Copy link

ksennoun commented Jun 2, 2014

Hmm, I have tested iPhones 4s 5 and 5c all running ios 7.1.x and they don't show any focus problem. You said that the problem is not limited to this plugin, did you repreduce it with an app that doesn't use zxing library? I'm afraid that this repo is currently being abandoned...

@dirtyrobinson
Copy link

I could not reproduce the focus bug using other libraries, I tried 3 apps that used the zxing library and 3 that didn't. Only the zxing libraries had the focus problem. Scanndit was the only other phonegap plugin I could find but being limited to the amount of scans you can use a month is a huge negative, plus it was much slower than this plugin.

@dpolivy
Copy link

dpolivy commented Jul 29, 2014

I've noticed the same problem -- on iPhone 4, the camera doesn't ever adjust the autofocus once the camera is capturing. Seems to work just fine on later models, though.

I found PR #129 with a fix for this issue, and after doing some further investigation myself, I found that all I really needed to do was to add the following line to the captureOutput: callback.

    [NSThread sleepForTimeInterval:0.001f];

This just blocks the thread for 1ms, and presumably yields enough time for the camera auto-focus code to kick in. Since I already set the camera to continuous auto focus mode and set a focal point in the capture session initialization, I found it wasn't necessary to reset these values in each run of the callback.

In general I'm not a fan of blocking like this, but it doesn't appear to impact the responsiveness of the app or the barcode recognition, plus it also lowers overall app CPU usage while the scanner is active (since it's not shoving as many frames through the processor). Hopefully this helps you out!

@michalzyka
Copy link

@dpolivy Thank you for your solution, it works perfectly!

@crissi
Copy link

crissi commented May 7, 2015

For a user not understanding object C. Can you explain exactly where I put that "[NSThread sleepForTimeInterval:0.001f];" @dpolivy @michalzyka. Thx

@dpolivy
Copy link

dpolivy commented May 7, 2015

@crissi I think you can just put it at the end of the captureOutput: callback, e.g. https://github.com/wildabeast/BarcodeScanner/blob/master/src/ios/CDVBarcodeScanner.mm#L521. I've long since rewritten this plugin to use a different (newer) version of zxing that works much better, so I don't have any code to reference for the exact location, sorry.

@crissi
Copy link

crissi commented May 7, 2015

Thx man. Will take a look at your fork

Christian

Den 07/05/2015 kl. 19.12 skrev Dan Polivy [email protected]:

@crissi I think you can just put it at the end of the captureOutput: callback, e.g. https://github.com/wildabeast/BarcodeScanner/blob/master/src/ios/CDVBarcodeScanner.mm#L521. I've long since rewritten this plugin to use a different (newer) version of zxing that works much better, so I don't have any code to reference for the exact location, sorry.


Reply to this email directly or view it on GitHub.

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

No branches or pull requests

7 participants