From 334bd407e0b2e187ce260926170b037e8aa794ea Mon Sep 17 00:00:00 2001 From: Michele Renzullo <76132686+michelerenzullo@users.noreply.github.com> Date: Thu, 24 Nov 2022 01:58:04 +0100 Subject: [PATCH] Add TryHarder and MinLineCount hints for python wrapper Added 2 hints to the python wrapper, MinLineCount and TryHarder --- wrappers/python/zxing.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/wrappers/python/zxing.cpp b/wrappers/python/zxing.cpp index 14dd5c7e7b..33f4643170 100644 --- a/wrappers/python/zxing.cpp +++ b/wrappers/python/zxing.cpp @@ -37,7 +37,7 @@ std::ostream& operator<<(std::ostream& os, const Position& points) { } auto read_barcodes_impl(py::object _image, const BarcodeFormats& formats, bool try_rotate, bool try_downscale, TextMode text_mode, - Binarizer binarizer, bool is_pure, EanAddOnSymbol ean_add_on_symbol, uint8_t max_number_of_symbols = 0xff) + Binarizer binarizer, bool is_pure, EanAddOnSymbol ean_add_on_symbol, bool try_harder, uint8_t min_line_count, uint8_t max_number_of_symbols = 0xff) { const auto hints = DecodeHints() .setFormats(formats) @@ -46,6 +46,8 @@ auto read_barcodes_impl(py::object _image, const BarcodeFormats& formats, bool t .setTextMode(text_mode) .setBinarizer(binarizer) .setIsPure(is_pure) + .setTryHarder(try_harder) + .setMinLineCount(min_line_count) .setMaxNumberOfSymbols(max_number_of_symbols) .setEanAddOnSymbol(ean_add_on_symbol); const auto _type = std::string(py::str(py::type::of(_image))); @@ -89,16 +91,16 @@ auto read_barcodes_impl(py::object _image, const BarcodeFormats& formats, bool t } std::optional read_barcode(py::object _image, const BarcodeFormats& formats, bool try_rotate, bool try_downscale, - TextMode text_mode, Binarizer binarizer, bool is_pure, EanAddOnSymbol ean_add_on_symbol) + TextMode text_mode, Binarizer binarizer, bool is_pure, EanAddOnSymbol ean_add_on_symbol, bool try_harder, uint8_t min_line_count) { - auto res = read_barcodes_impl(_image, formats, try_rotate, try_downscale, text_mode, binarizer, is_pure, ean_add_on_symbol, 1); + auto res = read_barcodes_impl(_image, formats, try_rotate, try_downscale, text_mode, binarizer, is_pure, ean_add_on_symbol, try_harder, min_line_count, 1); return res.empty() ? std::nullopt : std::optional(res.front()); } Results read_barcodes(py::object _image, const BarcodeFormats& formats, bool try_rotate, bool try_downscale, - TextMode text_mode, Binarizer binarizer, bool is_pure, EanAddOnSymbol ean_add_on_symbol) + TextMode text_mode, Binarizer binarizer, bool is_pure, EanAddOnSymbol ean_add_on_symbol, bool try_harder, uint8_t min_line_count) { - return read_barcodes_impl(_image, formats, try_rotate, try_downscale, text_mode, binarizer, is_pure, ean_add_on_symbol); + return read_barcodes_impl(_image, formats, try_rotate, try_downscale, text_mode, binarizer, is_pure, ean_add_on_symbol, try_harder, min_line_count); } Image write_barcode(BarcodeFormat format, std::string text, int width, int height, int quiet_zone, int ec_level) @@ -254,6 +256,8 @@ PYBIND11_MODULE(zxingcpp, m) py::arg("binarizer") = Binarizer::LocalAverage, py::arg("is_pure") = false, py::arg("ean_add_on_symbol") = EanAddOnSymbol::Ignore, + py::arg("try_harder") = true, + py::arg("min_line_count") = 1, "Read (decode) a barcode from a numpy BGR or grayscale image array or from a PIL image.\n\n" ":type image: numpy.ndarray|PIL.Image.Image\n" ":param image: The image object to decode. The image can be either:\n" @@ -279,6 +283,10 @@ PYBIND11_MODULE(zxingcpp, m) ":type ean_add_on_symbol: zxing.EanAddOnSymbol\n" ":param ean_add_on_symbol: Specify whether to Ignore, Read or Require EAN-2/5 add-on symbols while scanning \n" " EAN/UPC codes. Default is ``Ignore``.\n" + ":type try_harder: bool\n" + ":param try_harder: if ``True`` (the default), accuracy over performance.\n" + ":type min_line_count: uint8_t\n" + ":param min_line_count: Specify the minimum lines count to find.\n" ":rtype: zxing.Result\n" ":return: a zxing result containing decoded symbol if found, None otherwise" ); @@ -291,6 +299,8 @@ PYBIND11_MODULE(zxingcpp, m) py::arg("binarizer") = Binarizer::LocalAverage, py::arg("is_pure") = false, py::arg("ean_add_on_symbol") = EanAddOnSymbol::Ignore, + py::arg("try_harder") = true, + py::arg("min_line_count") = 1, "Read (decode) multiple barcodes from a numpy BGR or grayscale image array or from a PIL image.\n\n" ":type image: numpy.ndarray|PIL.Image.Image\n" ":param image: The image object to decode. The image can be either:\n" @@ -316,6 +326,10 @@ PYBIND11_MODULE(zxingcpp, m) ":type ean_add_on_symbol: zxing.EanAddOnSymbol\n" ":param ean_add_on_symbol: Specify whether to Ignore, Read or Require EAN-2/5 add-on symbols while scanning \n" " EAN/UPC codes. Default is ``Ignore``.\n" + ":type try_harder: bool\n" + ":param try_harder: if ``True`` (the default), accuracy over performance.\n" + ":type min_line_count: uint8_t\n" + ":param min_line_count: Specify the minimum lines count to find.\n" ":rtype: zxing.Result\n" ":return: a list of zxing results containing decoded symbols, the list is empty if none is found" ); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy