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: #1070 - OCR for packaging #2383

Merged
merged 2 commits into from
Jun 25, 2022

Conversation

monsieurtanuki
Copy link
Contributor

New files:

  • ocr_helper.dart: OCR Helper, to be implemented for ingredients and packaging for instance.
  • ocr_ingredients_helper.dart: OCR Helper for ingredients.
  • ocr_packaging_helper.dart: OCR Helper for packaging.
  • tmp_ocr_packaging_result.dart: to be moved to off-dart.

Impacted files:

  • app_en.arb: added 6 labels for packaging OCR.
  • edit_ingredients_page.dart: refactored around new class OcrHelper.
  • edit_product_page.dart: added access to edit packaging OCR; refactored.
  • knowledge_panels_builder.dart: refactored.
  • product_query.dart: added packaging fields to the product fields we get from the server.

What

  • Implementation of packaging OCR in the same spirit as ingredients OCR.

Screenshot

Capture d’écran 2022-06-25 à 19 20 34

Fixes bug(s)

New files:
* `ocr_helper.dart`: OCR Helper, to be implemented for ingredients and packaging for instance.
* `ocr_ingredients_helper.dart`: OCR Helper for ingredients.
* `ocr_packaging_helper.dart`: OCR Helper for packaging.
* `tmp_ocr_packaging_result.dart`: to be moved to off-dart.

Impacted files:
* `app_en.arb`: added 6 labels for packaging OCR.
* `edit_ingredients_page.dart`: refactored around new class `OcrHelper`.
* `edit_product_page.dart`: added access to edit OCR packaging; refactored.
* `knowledge_panels_builder.dart`: refactored.
* `product_query.dart`: added packaging fields to the product fields we get from the server.
@monsieurtanuki monsieurtanuki requested a review from a team as a code owner June 25, 2022 17:21
@codecov-commenter
Copy link

codecov-commenter commented Jun 25, 2022

Codecov Report

Merging #2383 (1f3a666) into develop (2ea0da3) will decrease coverage by 1.30%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           develop   #2383      +/-   ##
==========================================
- Coverage     8.86%   7.56%   -1.31%     
==========================================
  Files          161     204      +43     
  Lines         6623    9719    +3096     
==========================================
+ Hits           587     735     +148     
- Misses        6036    8984    +2948     
Impacted Files Coverage Δ
...kages/smooth_app/lib/widgets/attribute_button.dart 0.00% <0.00%> (-92.00%) ⬇️
...s/smooth_app/lib/data_models/user_preferences.dart 8.73% <0.00%> (-23.57%) ⬇️
packages/smooth_app/lib/themes/smooth_theme.dart 60.00% <0.00%> (-22.98%) ⬇️
...p/lib/generic_lib/dialogs/smooth_alert_dialog.dart 15.29% <0.00%> (-18.92%) ⬇️
...mooth_app/lib/data_models/product_preferences.dart 24.65% <0.00%> (-6.78%) ⬇️
packages/smooth_app/lib/main.dart 14.40% <0.00%> (-3.49%) ⬇️
.../smooth_app/lib/pages/onboarding/welcome_page.dart 0.00% <0.00%> (-3.13%) ⬇️
.../smooth_app/lib/pages/onboarding/scan_example.dart 0.00% <0.00%> (-2.28%) ⬇️
...p/lib/pages/onboarding/consent_analytics_page.dart 0.00% <0.00%> (-1.57%) ⬇️
...smooth_app/lib/pages/product/new_product_page.dart 0.00% <0.00%> (-0.88%) ⬇️
... and 203 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32545de...1f3a666. Read the comment docs.

…revious version

Impacted files:
* `edit_ingredients_page.dart`
* `ocr_helper.dart`
@monsieurtanuki monsieurtanuki requested a review from teolemon June 25, 2022 17:58
@teolemon teolemon added the ✏️ Editing - Packaging input Related to the structured input of food packaging. label Jun 25, 2022
@teolemon
Copy link
Member

👌

@teolemon teolemon added this to the V1.2 milestone Jun 25, 2022
Copy link
Member

@teolemon teolemon left a comment

Choose a reason for hiding this comment

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

Fine factoring work @monsieurtanuki 👌

@monsieurtanuki monsieurtanuki merged commit 2c0a31f into openfoodfacts:develop Jun 25, 2022
@monsieurtanuki
Copy link
Contributor Author

Thank you @teolemon for your review! Indeed I like to code in OOP.

Not sure how it works with packaging though: on one hand the server says "Papier,Envelope" (for "Wasa Fibres"), on the other hand the OCR says something totally different. How is transformed on the server side? How relevant is it for the user to read different things in the same entry field, depending on the purpose - user-friendly or OCR codes? To be continued, probably...

@teolemon
Copy link
Member

@monsieurtanuki The OCR-ized text is saved into the new per language field, which is parsed server side to feed the new packaging structure, which is used for Eco-Score computation.
The old structure (with commas) is leveraged when we have nothing in that field

@monsieurtanuki
Copy link
Contributor Author

@teolemon I don't know what to do then if we have two different ways of describing packaging: old fashioned "papier,envelope" and new packaging structure. Two text input fields, with one that can be filled with the OCR result?
We'll see how users react to the current page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✏️ Editing - Packaging input Related to the structured input of food packaging.
3 participants