-
Notifications
You must be signed in to change notification settings - Fork 703
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
Use TextureView instead of SurfaceView on Android. #459
base: master
Are you sure you want to change the base?
Conversation
This looks great!!! going to take a bit to review, but thanks so much for doing this work. Will post follow up questions yet i'm sure. |
using Android.Hardware; | ||
using Android.Runtime; | ||
|
||
namespace ApxLabs.FastAndroidCamera |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please change the namespace here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I kept the APXLabs namespace in:
CameraExtensions.cs
FastJavaByteArray.cs
FastJavaByteArrayEnumerator.cs
is that these files stems from: https://github.com/APXLabs/FastAndroidCamera. APXLabs is not my company, and even if the license permits me to change the namespace I felt it was a bit rude.
I only modified the files to use the JniEnvironment class (introduced with Xamarin.Android 6.1, if I recall correctly)
However I see that James Athey (the original author - https://github.com/jamesathey) has done some simlar fixes this september, and even released a nuget: https://www.nuget.org/packages/FastAndroidCamera/ Perhaps it would be better to reference this, what do you think?
As part of this, I think this has swayed me enough to completely drop support for < 4.0.3 (TextureView is only available on 4.0+). |
Can't really grok what fails on the build servers.. |
@@ -41,6 +42,9 @@ | |||
<HintPath>..\..\packages\Xamarin.Android.Support.v4.23.3.0\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll</HintPath> | |||
<Private>True</Private> | |||
</Reference> | |||
<Reference Include="FastAndroidCamera"> | |||
<HintPath>..\..\Samples\Forms\packages\FastAndroidCamera.2.0.0\lib\MonoAndroid403\FastAndroidCamera.dll</HintPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change hint path from Samples folder to ..\..\packages\....
@@ -94,6 +95,9 @@ | |||
<HintPath>..\..\packages\Xamarin.Forms.2.3.0.107\lib\MonoAndroid10\Xamarin.Forms.Xaml.dll</HintPath> | |||
<Private>True</Private> | |||
</Reference> | |||
<Reference Include="FastAndroidCamera"> | |||
<HintPath>..\..\Samples\Forms\packages\FastAndroidCamera.2.0.0\lib\MonoAndroid403\FastAndroidCamera.dll</HintPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here
Ahh I didn't realize this wasn't your code. Definitely in that case I wouldn't want to remove the namespace but I like the switch to a nuget dependency anyway. |
I'm going to take a shot at manually merging this tomorrow since I've just merged a big refactor of these related classes into master. Thanks for doing this work! Also, you inspired me to do the same type of work for iOS which saw some huge performance gains from the work I did on it this morning. Cheers! |
Sounds great. I will merge with master for you. Looking forward for your changes on the iOS side! |
All systems are go! |
@Redth, don't hesitate to contact me, if you have any questions/comments |
Thanks, I'm going to bring in the changes to ZXingSurfaceView first. We'll have to revisit some of the refactoring @f1nzer did around the android camera (it's coupled to SurfaceView) so that we can follow the same pattern with the TextureView implementation. |
Hi @Redth, |
Any news regarding this pull request? It is extensive fixes alot of issues, it would be a shame for it to go to waste. |
No; I haven't heard more from @Redth. I think he is busy with other stuff. I have created nugets for Android here: https://www.myget.org/F/custom-zxing-mobile/. I wasn't sure what to do with the version number, so it has the odd version 2.1.11 where 2.1 is taken from the original source, and 11 is my bitrise build number. |
@nielsenko sorry i dropped the ball on this one. I've finally got some of the android fast camera stuff into master and released. If you are open to it, I'd love this to be rebased on current master. If you're not able to get to that, I can always have a look... |
I'm a bit pressed for time right now, but I will give it a try, once I get around to it. |
…n FastJavaByteArrayYUVLuminanceSource and simplify CameraAnalyzer
Compared to existing ZXingSurfaceView, ZXingTextureView fixes the following: - Ensure correct aspect ratio, no matter what the view size. - Use background handler for all camera manipulation. - Crop preview to match viewfinder, so that you only scan what you see. - Avoid byte[] marshalling between Java and .Net runtime (FastJavaByteArray). - Return buffer to java runtime with camera.AddCallbackBuffer. - Avoid traslating from YCrCb to Rgb and back to luminance data (FastJavaByteArrayYUVLuminanceSource) - Re-use buffers, to avoid memory pressure, when rotating. - Automatically request autofocus on devices that does not support continous auto focus mode. - Prefer continous mode - For Xamarin.Forms ZXingScannerView now uses ZXingTextureView in the renderer on Android.
…d a FastJavaArrayEx.BlockCopyTo method to compensate for missing funtionality.
…ep a ringbuffer of recent barcodes, and honor DelayBetweenContinuousScans (of same barcode)
f857bfe
to
7d60a20
Compare
any update on this? |
I suppose we will never get this merged :( |
What's the hold up on this? |
@Softtinn My PR was an offshoot from a contract back in 2016 for a scandinavian postal service. I'm no longer involved with this project, so my personal interest has faded. I think @Redth was just busy with other stuff, and hence it never got merged. I'm not sure how many of these improvements has made it into master through other PRs. There has been quite a lot of releases since then. Today, I would probably use Google Vision instead (https://developers.google.com/vision/android/barcodes-overview) and Camera X (https://developer.android.com/training/camerax) |
I do plan on incorporating this in the future. Right now I’m too tied up with other pandemic related work so it may be a few weeks before I get back to this project yet. |
Compared to existing ZXingSurfaceView, ZXingTextureView fixes the following: