commit 693be7649a557fc0467888430d6dbb97576b6fc0 Author: Patrick Wadström Date: Sat Feb 3 10:42:32 2024 +0100 meh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..3e8f804 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,648 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" +dependencies = [ + "memchr", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bindgen" +version = "0.64.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4243e6031260db77ede97ad86c27e501d646a27ab57b59a574f725d98ab1fb4" +dependencies = [ + "bitflags 1.3.2", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 1.0.109", + "which", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" + +[[package]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "jobserver", + "libc", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c044c781163c001b913cd018fc95a628c50d0d2dfea8bca77dad71edb16e37" +dependencies = [ + "clang-sys", + "libc", +] + +[[package]] +name = "clang-sys" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "dunce" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" + +[[package]] +name = "either" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" + +[[package]] +name = "errno" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a258e46cdc063eb8519c00b9fc845fc47bcfca4130e2f08e88665ceda8474245" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "getrandom" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys 0.52.0", +] + +[[package]] +name = "jobserver" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d" +dependencies = [ + "libc", +] + +[[package]] +name = "jobslot" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69d354a626ad589ae49ba37a6c8c782e615813516f86eba9da15a390b1363b01" +dependencies = [ + "cfg-if", + "getrandom", + "libc", + "scopeguard", + "windows-sys 0.52.0", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "leptonica-plumbing" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "649bf19e77d43f7b8d2acc2e9a6ccabc373773f395205890f1ecc950fad7606c" +dependencies = [ + "leptonica-sys", + "libc", + "thiserror", +] + +[[package]] +name = "leptonica-sys" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335aadd5fa8d493d62d5596a980ce6ee823a72da45e89bcc45be3841e6d74bff" +dependencies = [ + "bindgen", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libc" +version = "0.2.152" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e3bf6590cbc649f4d1a3eefc9d5d6eb746f5200ffb04e5e142700b8faa56e7" + +[[package]] +name = "libloading" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161" +dependencies = [ + "cfg-if", + "windows-sys 0.48.0", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c" + +[[package]] +name = "log" +version = "0.4.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" + +[[package]] +name = "memchr" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149" + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-traits" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +dependencies = [ + "autocfg", +] + +[[package]] +name = "ocr-reciepts" +version = "0.1.0" +dependencies = [ + "opencv", + "tesseract", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "opencv" +version = "0.88.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96a686d8bc74fac172642bb5cb3fd2679ccc1b85d4f7ccedd273757174f1dbcd" +dependencies = [ + "cc", + "dunce", + "jobslot", + "libc", + "num-traits", + "once_cell", + "opencv-binding-generator", + "pkg-config", + "semver", + "shlex", + "vcpkg", +] + +[[package]] +name = "opencv-binding-generator" +version = "0.84.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e842c276fd00b26100de550e2b47f6ded4f06213c62f0575cb7242aecde2efd" +dependencies = [ + "clang", + "clang-sys", + "dunce", + "once_cell", + "percent-encoding", + "regex", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pkg-config" +version = "0.3.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2900ede94e305130c13ddd391e0ab7cbaeb783945ae07a279c268cb05109c6cb" + +[[package]] +name = "proc-macro2" +version = "1.0.78" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "regex" +version = "1.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b62dbe01f0b06f9d8dc7d49e05a0785f153b00b2c227856282f671e0318c9b15" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5bb987efffd3c6d0d8f5f89510bb458559eab11e4f869acb20bf845e016259cd" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "322394588aaf33c24007e8bb3238ee3e4c5c09c084ab32bc73890b99ff326bca" +dependencies = [ + "bitflags 2.4.2", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.52.0", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0" + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f3531638e407dfc0814761abb7c00a5b54992b849452a0646b7f65c9f770f3f" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tesseract" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "220d5c325aa2fa6656edd8924ad9a91d7ac7b5e998fe0f083a84f7f06ec9fda7" +dependencies = [ + "tesseract-plumbing", + "tesseract-sys", + "thiserror", +] + +[[package]] +name = "tesseract-plumbing" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fb02c52201d03517af73dd0a146ac62cbd6f0155ad3dc6455d0140d6112191" +dependencies = [ + "leptonica-plumbing", + "tesseract-sys", + "thiserror", +] + +[[package]] +name = "tesseract-sys" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd33f6f216124cfaf0fa86c2c0cdf04da39b6257bd78c5e44fa4fa98c3a5857b" +dependencies = [ + "bindgen", + "leptonica-sys", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "thiserror" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.48", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.0", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +dependencies = [ + "windows_aarch64_gnullvm 0.52.0", + "windows_aarch64_msvc 0.52.0", + "windows_i686_gnu 0.52.0", + "windows_i686_msvc 0.52.0", + "windows_x86_64_gnu 0.52.0", + "windows_x86_64_gnullvm 0.52.0", + "windows_x86_64_msvc 0.52.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..8dc2fc4 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "ocr-reciepts" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +opencv = { version = "0.88.8", features = ["clang-runtime"] } +tesseract = "0.15.1" diff --git a/DB_IC15_resnet18.onnx b/DB_IC15_resnet18.onnx new file mode 100644 index 0000000..e69f16d Binary files /dev/null and b/DB_IC15_resnet18.onnx differ diff --git a/alphabet_36.txt b/alphabet_36.txt new file mode 100644 index 0000000..7104368 --- /dev/null +++ b/alphabet_36.txt @@ -0,0 +1,36 @@ +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +a +b +c +d +e +f +g +h +i +j +k +l +m +n +o +p +q +r +s +t +u +v +w +x +y +z diff --git a/frozen_east_text_detection.pb b/frozen_east_text_detection.pb new file mode 100644 index 0000000..5702180 Binary files /dev/null and b/frozen_east_text_detection.pb differ diff --git a/outputbase.txt b/outputbase.txt new file mode 100644 index 0000000..08a0bfc --- /dev/null +++ b/outputbase.txt @@ -0,0 +1,71 @@ +sön of Tian + +Byggmax Kungsbacka +Borgås Gärdsväg 19 +434 39 Kungsbacka +Telefon 0771-89 00 89 +Org.nr 556645-6215 + +Kassakvitto + +28162 +VARNINGSFLAGGA 2 +21506 ie +PALLNINGSBRICKA 2MM 24-P +PALLNING 24-PACK 39,95 +22X45 YTTERPANEL 51,65 +7,80 MIR x 11,75/MTR sd, +08217035 + +SPONT. 17X95 ; +14,40 MTR x 13,95/MTR vh +08621057 +KLACKFODER 21X57 VIT +10,80 MTR x 59,95/MTR 1 +08728120 +IMPR. 28X120 TRÄLL ; +168,00 MTR x 18,90/MTR RR +09226 +HYLLPLAN MDF 595X2440X16 +440X18 349,00 +HÖRNSKYDD 2,5M SJÄLVHÄFTANDE +4 artiklar å 64,90 259,60 +Totalt 11 artiklar 4788,69 +Kort 4788 ,69 + +MS HandelsBan SE + +TERM: 13886571-505409/ 30413611 +2022-08-13 11:41 PERIOD :686 +VISA Contactless ppt 7553-1 + +AID: A0000000031010 +REF: 176725 839349 KAT TVR :0060000000 + +RESP: 00 + +KÖP SEK 4788,69 +Personlig kod + +GODKÄNT + +(Moms Z5k v -8830,05 = 967,J40 + +Du har blivit hjälpt av: Oskar Yckert + +Kvittonumner: 2632062410671 +But ik Säljare Nr Datum Tid +01.1210/02 2123 0464 2022-08-13 11:41 + +nen + +Spara kvittot för garantivaror. +öppet köp 1 365 dagar för butiksvaror. +För Webb och beställningsvaror tillämpas +30 dagars öppet köp +Virke, tillverkningsvaror och lister +bytes eller returneras ej. +För butikens öppettider se +www .byggnmax.se + +2 ÖR — RR diff --git a/outputbase.txt.txt b/outputbase.txt.txt new file mode 100644 index 0000000..8e93470 --- /dev/null +++ b/outputbase.txt.txt @@ -0,0 +1,71 @@ +ut ee a + +Byggmax Kungsbacka +Borgds Gardsvag 19 +434 39 Kungsbacka +Telefon 0771-89 00 89 +Org.nr 556645-6215 + +Kassakvitto + +28162 +VARNINGSFLAGGA 7 +21506 ~— +PALLNINGSBRICK4 2HM 24-P +PALLNING 24-PACK 39,95 +22X45 YTTERPANEL 91,65 +7,80 MIR x 11,75/MIR ad. +06217095 + +SPONT 17X95 5 +14,40 MIR x 13,95/MTR — +08621057 +KLACKFODER 21X57 YIT +10,80 MTR x 59,95/MTR i +08728120 +IMPR, 28X120 TRALL +168,00 MTR x 18,90/MTR li +09226 +HYLLPLAN MOF 595X2440X1¢ +oe 440X18 349,00 +HORNSKYDD 2,5 SJALYHAETANDE +4 artiklar a 64,90 259 , 60 +Totalt 11 artiklar 478869 +Kort 4788 , 69 + +MS HandelsBan 35 + +TERM: 1388657 1-505409/ 30413611 +2022-08-13 1:41 PERIOD :686 +VISA Contact less Jaap ERERAT 553 - 1 + +AID: A0000000031010 +REF: 176725 839345 KAI TVR :0000000000 + +RESP: 00 + +KOP SEK 4788 ,69 +Personlig kod + +GODKANT + +(Moms 25% x 3630,95 = 957,74 ) + +Du har blivit hjalpt av: Uskar Yekert + +Kvittonummer : 2632062410671 +Butik Saljare Nr Datum Tid +01.1210/02 2128 0464 2022-08-13 11:41 + +wn + +Spara kvittot fér garantivaror. +Gppet kip 1 365 dagar fir butiksvaror. +Fér Webb och bestal Iningsvaror til lémpas +30 dagars Gppet kop +Virke, tillverkningsvaror och jister +bytes eller returneras ej. +Fér butikens dppettider se +waw .bygamax . Se + +——————————EE——<—<————<<—<—— diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..a95de16 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,97 @@ +use std::error::Error; +use std::fs::File; +use std::io::{BufRead, BufReader}; + +use opencv::core::{Point, Point2f, Scalar, Size, Vector}; +use opencv::dnn::{TextDetectionModel_EAST, TextRecognitionModel}; +use opencv::prelude::*; +use opencv::{core, dnn, highgui, imgproc, videoio}; + +type Result> = std::result::Result; + +pub fn parse_data(data: &str) { + let lines = data.split('\n').collect::>(); + for line in lines { + println!("{}", line); + } +} + +pub fn ocr() { + let mut engine = tesseract::Tesseract::new(None, Some("swe")).unwrap(); + engine.set_page_seg_mode(tesseract::PageSegMode::PsmAutoOnly); + engine = engine.set_image("test.jpg").unwrap().recognize().unwrap(); + parse_data(&engine.get_text().unwrap()); +} + +fn main() -> Result<()> { + // Load networks. + let mut detector = TextDetectionModel_EAST::from_file("frozen_east_text_detection.pb", "")?; + detector + .set_confidence_threshold(0.5)? + .set_nms_threshold(0.4)?; + let mut recognizer = TextRecognitionModel::from_file("DB_IC15_resnet18.onnx", "")?; + + // Load vocabulary + let mut vocabulary = Vector::::new(); + let voc_file = BufReader::new(File::open("alphabet_36.txt")?); + for voc_line in voc_file.lines() { + vocabulary.push(&voc_line?); + } + recognizer + .set_vocabulary(&vocabulary)? + .set_decode_type("CTC-greedy")?; + + // Parameters for Recognition + let rec_scale = 1. / 127.5; + let rec_mean = Scalar::from((127.5, 127.5, 127.5)); + let rec_input_size = Size::new(100, 32); + recognizer.set_input_params(rec_scale, rec_input_size, rec_mean, false, false)?; + + // Parameters for Detection + let det_scale = 1.; + let det_input_size = Size::new(320, 320); + let det_mean = Scalar::from((123.68, 116.78, 103.94)); + let swap_rb = true; + detector.set_input_params(det_scale, det_input_size, det_mean, swap_rb, false)?; + + let mut img = opencv::imgcodecs::imread("test.jpg", opencv::imgcodecs::IMREAD_COLOR)?; + + let mut det_results = Vector::new(); + detector.detect(&img, &mut det_results)?; + + if !det_results.is_empty() { + // Text Recognition + let mut contours = Vector::>::new(); + for quadrangle in &det_results { + let mut quadrangle_2f = Vector::::new(); + for pt in &quadrangle { + quadrangle_2f.push(Point2f::new(pt.x as f32, pt.y as f32)) + } + let cropped = four_points_transform(&img, quadrangle_2f.as_slice())?; + let recognition_result = recognizer.recognize(&cropped)?; + println!("Recognition result: {recognition_result}"); + contours.push(quadrangle); + } + println!("contours {:#?}", contours); + } + + Ok(()) +} + +fn four_points_transform(frame: &Mat, vertices: &[Point2f]) -> Result { + let output_size = Size::new(100, 32); + let target_vertices = [ + Point2f::new(0., (output_size.height - 1) as f32), + Point2f::new(0., 0.), + Point2f::new((output_size.width - 1) as f32, 0.), + Point2f::new( + (output_size.width - 1) as f32, + (output_size.height - 1) as f32, + ), + ]; + let rotation_matrix = + imgproc::get_perspective_transform_slice(vertices, &target_vertices, core::DECOMP_LU)?; + let mut out = Mat::default(); + imgproc::warp_perspective_def(frame, &mut out, &rotation_matrix, output_size)?; + Ok(out) +} diff --git a/test.jpg b/test.jpg new file mode 100755 index 0000000..c564e48 Binary files /dev/null and b/test.jpg differ