From e497e036ec6a2baa76a409ab6fd8e4a77da22561 Mon Sep 17 00:00:00 2001 From: JKamsker <11245306+JKamsker@users.noreply.github.com> Date: Wed, 5 Jul 2023 23:28:22 +0200 Subject: [PATCH] Add hex value to wasm result --- .gitignore | 2 ++ wrappers/wasm/BarcodeReader.cpp | 4 +++- wrappers/wasm/demo_reader.html | 7 +++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 9992cb687a..1597a08e1a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ CMakeLists.txt.user *.d *.a compile_commands.json +build/ +.vscode/ diff --git a/wrappers/wasm/BarcodeReader.cpp b/wrappers/wasm/BarcodeReader.cpp index e56762e490..de57708166 100644 --- a/wrappers/wasm/BarcodeReader.cpp +++ b/wrappers/wasm/BarcodeReader.cpp @@ -20,6 +20,7 @@ struct ReadResult { std::string format{}; std::string text{}; + std::string hex{}; std::string error{}; Position position{}; std::string symbologyIdentifier{}; @@ -43,7 +44,7 @@ std::vector readBarcodes(ImageView iv, bool tryHarder, const std::st readResults.reserve(results.size()); for (auto& result : results) { - readResults.push_back({ToString(result.format()), result.text(), ToString(result.error()), result.position(), result.symbologyIdentifier()}); + readResults.push_back({ToString(result.format()), result.text(), ToHex(result.bytes()), ToString(result.error()), result.position(), result.symbologyIdentifier()}); } return readResults; @@ -89,6 +90,7 @@ EMSCRIPTEN_BINDINGS(BarcodeReader) value_object("ReadResult") .field("format", &ReadResult::format) .field("text", &ReadResult::text) + .field("hex", &ReadResult::hex) .field("error", &ReadResult::error) .field("position", &ReadResult::position) .field("symbologyIdentifier", &ReadResult::symbologyIdentifier); diff --git a/wrappers/wasm/demo_reader.html b/wrappers/wasm/demo_reader.html index cbcb7cfcca..ed4d8da596 100644 --- a/wrappers/wasm/demo_reader.html +++ b/wrappers/wasm/demo_reader.html @@ -78,8 +78,11 @@ } else { for (let i = 0; i < results.size(); i += 1) { - const { error, format, text } = results.get(i); - resultsDiv.innerHTML += "
  • Format: " + format + "
    " + (text || 'Error: ' + error + '') + "
  • "; + const { error, format, text, hex } = results.get(i); + resultsDiv.innerHTML += "
  • Format: " + format + "" + + "

    Hex:" + hex + "

    " + + "
    " + (text || 'Error: ' + error + '') + "
    "+ + +"
  • "; } } } 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