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

Port ZXing Android to Camera2 #963

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
0c588b2
Ported to camera2
Dec 11, 2020
9f6acb4
Refactoring
Dec 11, 2020
a62bb1c
Fixed distorted preview
Dec 14, 2020
648d772
Cleanup
Dec 21, 2020
fc35548
Removed obsolet boundary check for auto focus
Denrage Jan 19, 2021
8850ea0
Add new Nv21 implementation
jameswestgate Feb 4, 2021
6d7930b
Dont create new BarcodeReader on every decode
jameswestgate Feb 4, 2021
80653d2
Merge pull request #1 from jameswestgate/android-camera2
Denrage Feb 5, 2021
5b3b0db
removed obsolet code
Denrage Feb 5, 2021
d38b362
Removed FastAndroidCamera
Denrage Feb 5, 2021
9b1eb53
Merge branch 'master' into android-camera2
Denrage Feb 5, 2021
a50c5b7
Fixed Merge
Denrage Feb 5, 2021
cbcabcd
rotate yuv output
Denrage Feb 5, 2021
642de3c
Fixed scanning on tablet and sped up conversion
Denrage Mar 10, 2021
5d56763
Fixed distortion of camera preview
Denrage Mar 10, 2021
a8478b1
Select lowest resolution for faster analyze
Jun 9, 2021
34e83d2
Use a minimum size to prevent using a resolution too small
Jul 1, 2021
b9b99f3
Updated ZXing Lib
Jul 18, 2022
af54b7f
Add DebugHelper.android.cs class
Jul 18, 2022
21e4008
Improved read speed a little bit and better recognition for bar codes
Jul 18, 2022
4c86173
Spacings
Jul 18, 2022
3c120fa
Allow tools folder
Jul 18, 2022
9ad0062
Added ImageReceiver Tool
Jul 18, 2022
f978965
typo fixed
Jul 18, 2022
6b0c54d
Prefere slight distortion but see whats on screen
Jul 18, 2022
dd2e259
Use helper class CapturedImageData
Aug 2, 2022
c5d8631
Call AutoFocus at least once
Aug 2, 2022
7af01bf
if available and not other given, use continousvideo mode für auto focus
Aug 2, 2022
7248a26
Use ideal sizes and update accordingly
Aug 2, 2022
7507b08
Better LuminanceSource for nv21
Aug 3, 2022
124104c
Small adjustment in yuv420 to nv21 converter
Aug 3, 2022
485a094
Use the improved LuminanceSource with correct rotation
Aug 3, 2022
c611598
Changed ImageReader instances to 3
Aug 3, 2022
b547648
Some Debug Helper improvements
Aug 4, 2022
6cc85dc
Better initial image rotation
Aug 4, 2022
d0cfe36
Adjusted Log Message
Aug 4, 2022
8eb531c
Fixed Bug where potrait images gets rotated because of device orienta…
Aug 4, 2022
e77093c
Moved initializing orientationdata for logging
Aug 4, 2022
4edae28
Adjusted Optimal Sizes for quality and performance
Aug 4, 2022
485c809
More samples since we got lower decode times
Aug 4, 2022
d557537
Debug call example
Aug 5, 2022
67a8abc
adjusted how the optimal sizes get determined
Aug 5, 2022
8b6cc79
Fallback for OptimalSize
Aug 5, 2022
8fe06c1
More OptimalSize adjustments
Aug 5, 2022
9f23195
Fixed image bending to a certain degree
Aug 5, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -39,7 +39,6 @@ TestCloud/
.vs/
project.lock.json

tools/
.nugetapikey
.mygetapikey
*.xam
Expand Down
1 change: 0 additions & 1 deletion Samples/Sample.Android/Sample.Android.csproj
Expand Up @@ -89,7 +89,6 @@
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<ItemGroup>
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.2.0.6" />
<PackageReference Include="FastAndroidCamera" Version="2.0.0" />
<PackageReference Include="Xamarin.AndroidX.Browser">
<Version>1.3.0.4</Version>
</PackageReference>
Expand Down
Expand Up @@ -109,4 +109,9 @@
<AndroidResource Include="Resources\mipmap-xxxhdpi\launcher.png" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<UserProperties TriggeredFromHotReload="False" />
</VisualStudio>
</ProjectExtensions>
</Project>
2 changes: 1 addition & 1 deletion Samples/Sample.Forms/Sample.Forms/Sample.Forms.csproj
Expand Up @@ -13,7 +13,7 @@
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="5.0.0.1874" />
<PackageReference Include="Xamarin.Essentials" Version="1.6.0" />
<PackageReference Include="ZXing.Net" Version="0.16.6" />
<PackageReference Include="ZXing.Net" Version="0.16.8" />
</ItemGroup>

<ItemGroup>
Expand Down
9 changes: 9 additions & 0 deletions Tools/ImageReceiver/ImageReceiver.csproj
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

</Project>
37 changes: 37 additions & 0 deletions Tools/ImageReceiver/Program.cs
@@ -0,0 +1,37 @@

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

var picNum = 0;

var imagePath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)!, "Images");
Directory.CreateDirectory(imagePath);
Console.WriteLine($"Saving images to: {imagePath}");


app.MapPost("/", async context =>
{
try
{
var filePrefix = "File";
if (context.Request.Headers.TryGetValue("FileName", out var newFilePrefix))
{
filePrefix = newFilePrefix;
}

using (var fs = File.Create(Path.Combine(imagePath, $"{filePrefix}_{picNum}.bmp")))
{
picNum++;
await context.Request.Body.CopyToAsync(fs);
}
}
catch (Exception ex)
{
Console.Error.WriteLine($"Failed to save File_{picNum - 1}.bmp");
Console.Error.WriteLine(ex.Message);
}

context.Response.StatusCode = 200;
});

app.Run();
27 changes: 27 additions & 0 deletions Tools/ImageReceiver/Properties/launchSettings.json
@@ -0,0 +1,27 @@
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:63208",
"sslPort": 0
}
},
"profiles": {
"ImageReceiver": {
"commandName": "Project",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:5390",
"dotnetRunMessages": true
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
8 changes: 8 additions & 0 deletions Tools/ImageReceiver/appsettings.Development.json
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions Tools/ImageReceiver/appsettings.json
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
2 changes: 1 addition & 1 deletion ZXing.Net.Mobile.Forms/ZXing.Net.Mobile.Forms.csproj
Expand Up @@ -89,7 +89,7 @@
<ItemGroup>
<PackageReference Include="Xamarin.Essentials" Version="1.6.0" />
<PackageReference Include="Xamarin.Forms" Version="5.0.0.1874" />
<PackageReference Include="ZXing.Net" Version="0.16.6" />
<PackageReference Include="ZXing.Net" Version="0.16.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZXing.Net.Mobile\ZXing.Net.Mobile.csproj" />
Expand Down
65 changes: 63 additions & 2 deletions ZXing.Net.Mobile.sln
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
# Visual Studio Version 17
VisualStudioVersion = 17.2.32616.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ZXing.Net.Mobile", "ZXing.Net.Mobile\ZXing.Net.Mobile.csproj", "{8B7A8AB6-35A4-4C9C-83E1-96BA8BE3C941}"
EndProject
Expand Down Expand Up @@ -32,6 +32,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Forms.UWP", "Samples
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.Forms.Tizen", "Samples\Sample.Forms\Sample.Forms.Tizen\Sample.Forms.Tizen.csproj", "{9CBD2F34-9649-48DE-9B35-0D1291F4E714}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{09527748-5F83-45A9-B1A4-DB3C85D136FB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImageReceiver", "Tools\ImageReceiver\ImageReceiver.csproj", "{47387C60-8776-44DE-A73E-8D6C72D9BC43}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Ad-Hoc|Any CPU = Ad-Hoc|Any CPU
Expand Down Expand Up @@ -686,6 +690,62 @@ Global
{9CBD2F34-9649-48DE-9B35-0D1291F4E714}.Release|x64.Build.0 = Release|Any CPU
{9CBD2F34-9649-48DE-9B35-0D1291F4E714}.Release|x86.ActiveCfg = Release|Any CPU
{9CBD2F34-9649-48DE-9B35-0D1291F4E714}.Release|x86.Build.0 = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|ARM.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|ARM.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|ARM64.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|ARM64.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|x64.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|x64.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|x86.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Ad-Hoc|x86.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|ARM.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|ARM.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|ARM64.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|ARM64.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|iPhone.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|x64.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|x64.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|x86.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.AppStore|x86.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|ARM.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|ARM.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|ARM64.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|iPhone.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|x64.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|x64.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|x86.ActiveCfg = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Debug|x86.Build.0 = Debug|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|Any CPU.Build.0 = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|ARM.ActiveCfg = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|ARM.Build.0 = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|ARM64.ActiveCfg = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|ARM64.Build.0 = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|iPhone.ActiveCfg = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|iPhone.Build.0 = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|x64.ActiveCfg = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|x64.Build.0 = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|x86.ActiveCfg = Release|Any CPU
{47387C60-8776-44DE-A73E-8D6C72D9BC43}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -699,6 +759,7 @@ Global
{CFF9673E-1188-4646-BCC7-F7601F3A1D1A} = {E0DF8E5D-AF49-43C9-9921-D67268E75964}
{96FBFDD1-F91A-44F6-962A-51E1AC7AAC63} = {E0DF8E5D-AF49-43C9-9921-D67268E75964}
{9CBD2F34-9649-48DE-9B35-0D1291F4E714} = {E0DF8E5D-AF49-43C9-9921-D67268E75964}
{47387C60-8776-44DE-A73E-8D6C72D9BC43} = {09527748-5F83-45A9-B1A4-DB3C85D136FB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {887F72FF-99D0-4882-A73A-A913A0534F0C}
Expand Down