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

feat: Use Imager::zxing to read barcodes from uploaded images #9051

Merged
merged 22 commits into from
Nov 29, 2023

Conversation

hangy
Copy link
Member

@hangy hangy commented Sep 21, 2023

What

Use Perl module Imager::zxing to read barcodes from images to enable support for more barcode types that are not supported by Barcode::ZBar, ie. DataMatrix. By passing the values to GS1::SyntaxEngine::FFI, this allows GS1 Data URI, GS1 DataMatrix, and GS1 QR Code barcodes to be used & parsed when uploading images to Product Opener.

Related issue(s) and discussion

@hangy hangy added barcodes 🖼️ Image upload GS1 The producer platform is integrating with the GS1 product data formats. GS1 manages barcodes. labels Sep 21, 2023
@hangy hangy self-assigned this Sep 21, 2023
@hangy hangy marked this pull request as ready for review September 21, 2023 14:51
@hangy hangy requested a review from a team as a code owner September 21, 2023 14:51
@github-actions github-actions bot added the 💥 Merge Conflicts 💥 Merge Conflicts label Sep 21, 2023
@github-actions github-actions bot removed the Products label Sep 21, 2023
@sonarcloud
Copy link

sonarcloud bot commented Sep 21, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Comparison is base (7fb9bba) 48.84% compared to head (200bd7f) 48.99%.

Files Patch % Lines
lib/ProductOpener/Images.pm 68.18% 3 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9051      +/-   ##
==========================================
+ Coverage   48.84%   48.99%   +0.14%     
==========================================
  Files          66       66              
  Lines       20380    20398      +18     
  Branches     4891     4896       +5     
==========================================
+ Hits         9955     9993      +38     
+ Misses       9166     9138      -28     
- Partials     1259     1267       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot removed the 💥 Merge Conflicts 💥 Merge Conflicts label Sep 22, 2023
@github-actions github-actions bot removed the GS1 The producer platform is integrating with the GS1 product data formats. GS1 manages barcodes. label Nov 4, 2023
@teolemon
Copy link
Member

teolemon commented Nov 9, 2023

@hangy @alexgarel WDYT ?

@hangy
Copy link
Member Author

hangy commented Nov 9, 2023

@teolemon The change depends on the moving to the new(?) server (new Debian version) #8827

@alexgarel
Copy link
Member

@hangy this could be merged now I think as we moved to the new server :-)

Copy link

sonarcloud bot commented Nov 29, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@hangy hangy enabled auto-merge (squash) November 29, 2023 09:18
Copy link
Member

@alexgarel alexgarel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank @hangy !
LGTM, just some minor comments or explanations needed.

}
}

if (not(defined $code)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (not(defined $code)) {
# zbar failed, try with zxing
if (not(defined $code)) {

$code = $result->text();
my $type = $result->format();
$log->debug("barcode found", {code => $code, type => $type}) if $log->is_debug();
print STDERR "scan_code code found: $code\n";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better remove this :-)

Suggested change
print STDERR "scan_code code found: $code\n";

my $type = $result->format();
$log->debug("barcode found", {code => $code, type => $type}) if $log->is_debug();
print STDERR "scan_code code found: $code\n";
if (($code !~ /^\d+|(?:[\^(\N{U+001D}\N{U+241D}]|https?:\/\/).+$/)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting is a must have here :-)

I'm not able to understand what the [\^(\N{U+001D}\N{U+241D}] is for !

Suggested change
if (($code !~ /^\d+|(?:[\^(\N{U+001D}\N{U+241D}]|https?:\/\/).+$/)) {
# we want a sequence of numbers,
# or a url
if (($code !~ /^\d+|(?:[\^(\N{U+001D}\N{U+241D}]|https?:\/\/).+$/)) {

["08_gs1_databar_stacked_omni.jpg", "5010029000214"],
["37_gs1_datamatrix.jpg", "0725272730706"],
["43_gs1_qrcode_digital_link.jpg", "9506000134369"],
["52_gs1_datamatrix_digital_link.jpg", "5010029000214"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
["52_gs1_datamatrix_digital_link.jpg", "5010029000214"]
# extracted from https://id.gs1.org/01/05010029000214/10/AbC/21/666?17=301010
["52_gs1_datamatrix_digital_link.jpg", "5010029000214"]

["07_gs1_databar_stacked.jpg", "5010029000214"],
["08_gs1_databar_stacked_omni.jpg", "5010029000214"],
["37_gs1_datamatrix.jpg", "0725272730706"],
["43_gs1_qrcode_digital_link.jpg", "9506000134369"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
["43_gs1_qrcode_digital_link.jpg", "9506000134369"],
# extracted from https://dalgiardino.com/01/09506000134369/10/ABC/21/123456?17=230829
["43_gs1_qrcode_digital_link.jpg", "9506000134369"],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update barcode recognition to understand more barcode types
4 participants