-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Huawei P9 it not work #287
Comments
我这边也一样,不报异常但是什么都识别不了,努比亚的手机也是,识别率奇低,三重识别都没用,麻烦的是我们的产品是面向工厂的,工厂老板都爱用华为手机,头疼 |
@vickyleu English please. :) |
Hmm based on similar bug report here https://github.com/oney/react-native-webrtc/issues/215, tend to think it might have to do something with deprecated Camera api. Since I don't have a P9 device with me, would it be possible for you to make sure your app first has the camera permissions? Thank you. |
@dm77 I'm sure has granted camera permission. |
@dm77 Granted, for sure. Probably deprecated Camera1 API. Camera2 API usage needed. |
Now. I fix this problem with PR #293. |
getOptimalPreviewSize method at CameraPreview , the algorithm is wrong. |
@dm77 width 1080 height 1572 huawei p9, the result is 144 * 208 |
change the if statement if (Math.abs(size.height - targetHeight) < minDiff && size.height >= 480) { now is ok, point is size.height >= 480 |
Thanks @vagrant1991 |
@vagrant1991 @WeRockStar You both had different solutions for the problem. @WeRockStar - you had somebody verify your commit (#293) and so I went with a slight variation of yours for now. I didn't want to hardcode the aspect tolerance to 0.5 like you did, but wanted it to be customizable. For example take a look at the setAspectTolerance call in this example: https://github.com/dm77/barcodescanner/blob/master/zxing-sample/src/main/java/me/dm7/barcodescanner/zxing/sample/ScalingScannerActivity.java#L35 Note that this is just a temporary fix. I still don't have a good grasp of what the issue is. My questions to any of you experiencing issues on Huawei devices: 1.) Do you always see this error: "Exception: Camera new cameraInitNormal: 0" ? This temporary fix is in v1.9.4 May be I should buy myself a Huawei device to test this out. |
@dm77 You saved my day! Thank you very much for the aspect tolerance! |
thanks, solved my problem about HUAWEI P10. |
@WeRockStar @dm77 @vickyleu @danielcerny @aegamesi @sg552 The point is not ASPECT_TOLERANCE size, the point is getOptimalPreviewSize method can't achieve the desired result on different devices. maybe huawei p9 p8 p10 p... other device..... There is no exception, I can reproduce always, "it won't work" mean the viewfinderview is blurred, because onPreviewFrame method at ZXingScannerView can't get the right camera size. It's irrelevant to Camera API (Camera vs Camera2) change the method to :
Now , all devices are ok. Try to get the first camera size which is larger than the size of viewfinderview |
@dm77 @vagrant1991 I was having poor results with v1.9.8. Swapping in the method above solved the problems I was having. Here were the issues I was having...
The above method solved these problems and it scans as I would expect. It is also much more helpful that you don't have to specify an ASPECT_TOLERANCE. In my opinion, this should be the method used for getOptimalPreviewSize() rather than what is currently used in v1.9.8. Hopefully others can come forward and discuss their results with this method. ALSO, if anyone is wondering the values of the constants (such as LANDSCAPE_WIDTH_HEIGHT_RATIO) they are found in the ViewFinderView.java file. I'd be happy to put together a pull-request @dm77 if you are interested. Thanks! |
+1 for pull request mentioned by stephenruda |
Hi guys, In my case I discovered that the problem was related to the action bar. If you check the sample app it has set What I did to workaround this issue is to set in the manifest file the following style to my activity:
I hope this can help you, please let me know if you have any problem. |
Hi @vagrant1991 When I try to replace the method with yours 'getOptimalPreviewSize', I'm getting the following as unresolved symbols: mSquareViewFinder Can you please help? I'm kind of new to all this. Or, if you have an aar/jar with the above method already replaced, can you please share it? We're running into an issue for specific devices. Didn't expect this to happen, so need a solution. Thanks. |
…ssue. Adapted patch suggested by @vagrant1991. See discussion at dm77#287
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Exception: Camera new cameraInitNormal: 0
The text was updated successfully, but these errors were encountered: