Connect ocrs to new ui
This commit is contained in:
227
Cargo.lock
generated
227
Cargo.lock
generated
@@ -10,9 +10,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.81"
|
version = "1.0.82"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0952808a6c2afd1aa8947271f3a60f1a6763c7b912d210184c5149b5cf147247"
|
checksum = "f538837af36e6f6a9be0faa67f9a314f8119e4e4b5867c6ab40ed60360142519"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayvec"
|
name = "arrayvec"
|
||||||
@@ -22,9 +22,9 @@ checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.1.0"
|
version = "1.3.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit_field"
|
name = "bit_field"
|
||||||
@@ -40,21 +40,21 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.4.2"
|
version = "2.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
|
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.15.0"
|
version = "3.16.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d32a994c2b3ca201d9b263612a374263f05e7adde37c4707f693dcd375076d1f"
|
checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytemuck"
|
name = "bytemuck"
|
||||||
version = "1.14.3"
|
version = "1.15.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a2ef034f05691a48569bd920a96c81b9d91bbad1ab5ac7c4616c1f6ef36cb79f"
|
checksum = "5d6d68c57235a3a081186990eca2867354726650f42f7516ca50c28d6281fd15"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck_derive",
|
"bytemuck_derive",
|
||||||
]
|
]
|
||||||
@@ -82,7 +82,7 @@ version = "0.12.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298"
|
checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.5.0",
|
||||||
"log",
|
"log",
|
||||||
"polling",
|
"polling",
|
||||||
"rustix",
|
"rustix",
|
||||||
@@ -104,12 +104,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.0.83"
|
version = "1.0.96"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
|
checksum = "065a29261d53ba54260972629f9ca6bffa69bac13cd1fed61420f7fa68b9f8bd"
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfg-if"
|
||||||
@@ -125,9 +122,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "concurrent-queue"
|
name = "concurrent-queue"
|
||||||
version = "2.4.0"
|
version = "2.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d16048cd947b08fa32c24458a22f5dc5e835264f689f4f5653210c69fd107363"
|
checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
]
|
]
|
||||||
@@ -272,9 +269,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "downcast-rs"
|
name = "downcast-rs"
|
||||||
version = "1.2.0"
|
version = "1.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dwrote"
|
name = "dwrote"
|
||||||
@@ -290,9 +287,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "either"
|
name = "either"
|
||||||
version = "1.10.0"
|
version = "1.11.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a"
|
checksum = "a47c1c47d2f5964e29c61246e81db715514cd532db6b5116a25ea3c03d6780a2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "errno"
|
name = "errno"
|
||||||
@@ -350,9 +347,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.28"
|
version = "1.0.30"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e"
|
checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crc32fast",
|
"crc32fast",
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
@@ -379,7 +376,7 @@ version = "0.13.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d50ba02d3a19ab9012a00314ff4d105128cdc7ba223d69d48181f2d257244d51"
|
checksum = "d50ba02d3a19ab9012a00314ff4d105128cdc7ba223d69d48181f2d257244d51"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.5.0",
|
||||||
"byteorder",
|
"byteorder",
|
||||||
"core-foundation",
|
"core-foundation",
|
||||||
"core-graphics",
|
"core-graphics",
|
||||||
@@ -448,9 +445,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.2.12"
|
version = "0.2.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5"
|
checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -469,14 +466,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "half"
|
name = "half"
|
||||||
version = "2.3.1"
|
version = "2.4.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bc52e53916c08643f1b56ec082790d1e86a32e58dc5268f897f313fbae7b4872"
|
checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"crunchy",
|
"crunchy",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.3.9"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "image"
|
name = "image"
|
||||||
version = "0.24.9"
|
version = "0.24.9"
|
||||||
@@ -527,9 +530,9 @@ checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.153"
|
version = "0.2.154"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
|
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
@@ -553,7 +556,7 @@ version = "0.1.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.5.0",
|
||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -565,9 +568,9 @@ checksum = "01cda141df6706de531b6c46c3a33ecca755538219bd484262fa09410c13539c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lock_api"
|
name = "lock_api"
|
||||||
version = "0.4.11"
|
version = "0.4.12"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
|
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"scopeguard",
|
"scopeguard",
|
||||||
@@ -575,9 +578,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.20"
|
version = "0.4.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lyon_geom"
|
name = "lyon_geom"
|
||||||
@@ -592,9 +595,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.7.1"
|
version = "2.7.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memmap2"
|
name = "memmap2"
|
||||||
@@ -626,9 +629,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.18"
|
version = "0.2.19"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
|
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"libm",
|
"libm",
|
||||||
@@ -636,10 +639,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ocrs"
|
name = "ocrs"
|
||||||
version = "0.4.0"
|
version = "0.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dfd2f495d2171a0e9eb972c2a8568b2dca7d56777e6ec7e54f974f36b532c340"
|
checksum = "8d730843ad91056514776a5f3a830379d73d93c88cf30424301bf9ba54e5b182"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rten",
|
"rten",
|
||||||
"rten-imageproc",
|
"rten-imageproc",
|
||||||
@@ -674,9 +678,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pin-project-lite"
|
name = "pin-project-lite"
|
||||||
version = "0.2.13"
|
version = "0.2.14"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
|
checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pkg-config"
|
name = "pkg-config"
|
||||||
@@ -699,12 +703,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polling"
|
name = "polling"
|
||||||
version = "3.5.0"
|
version = "3.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "24f040dee2588b4963afb4e420540439d126f73fdacf4a9c486a96d840bac3c9"
|
checksum = "645493cf344456ef24219d02a768cf1fb92ddf8c92161679ae3d91b91a637be3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
|
"hermit-abi",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"rustix",
|
"rustix",
|
||||||
"tracing",
|
"tracing",
|
||||||
@@ -713,9 +718,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.78"
|
version = "1.0.81"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae"
|
checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
@@ -740,9 +745,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.35"
|
version = "1.0.36"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
@@ -764,9 +769,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rayon"
|
name = "rayon"
|
||||||
version = "1.8.1"
|
version = "1.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fa7237101a77a10773db45d62004a272517633fbcc3df19d96455ede1122e051"
|
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"either",
|
"either",
|
||||||
"rayon-core",
|
"rayon-core",
|
||||||
@@ -795,42 +800,49 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rten"
|
name = "rten"
|
||||||
version = "0.3.1"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "67842141586c527d25547bbd81ccfd60601940281a792bce14a3f72dc15a3fec"
|
checksum = "ed8c84990cfa2d35011d40e0a8f5ad6d1a877dd80f513f04a2a070445cdd82f2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"flatbuffers",
|
"flatbuffers",
|
||||||
"libm",
|
"libm",
|
||||||
"rayon",
|
"rayon",
|
||||||
"rten-tensor",
|
"rten-tensor",
|
||||||
"rten-vecmath",
|
"rten-vecmath",
|
||||||
|
"rustc-hash",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rten-imageproc"
|
name = "rten-imageproc"
|
||||||
version = "0.3.0"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d9ceab28b8dcb8925ebc6e51f0038fd16e1cd68229e596eadef826ec7794747f"
|
checksum = "6d26fd4e8299e8c9b37affb04836a6d1ac67fee62a157a7b06b3cdc9d9b66e40"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rten-tensor",
|
"rten-tensor",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rten-tensor"
|
name = "rten-tensor"
|
||||||
version = "0.3.0"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b00a55ca04d3219957737f87a9fc3f6eee6770e1f1643c2094c032c90c43f0d2"
|
checksum = "4d2541dfaf69014c2e730f8386fc9647ddc0c3381b1fe21ce1640f0ed4f74357"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"smallvec",
|
"smallvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rten-vecmath"
|
name = "rten-vecmath"
|
||||||
version = "0.3.0"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ae896b8b5bea024dab45f9c8ee71051dfbf2a20a83b0e4e48cea5c4e7096e84"
|
checksum = "fc89d64420a5b7a7d74e3b5cc9424029a2ce86906cdaed50491c44e6f1a090f8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-hash"
|
||||||
|
version = "1.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc_version"
|
name = "rustc_version"
|
||||||
@@ -843,11 +855,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "0.38.31"
|
version = "0.38.34"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6ea3e1a662af26cd7a3ba09c0297a31af215563ecf42817c98df621387f4e949"
|
checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.5.0",
|
||||||
"errno",
|
"errno",
|
||||||
"libc",
|
"libc",
|
||||||
"linux-raw-sys",
|
"linux-raw-sys",
|
||||||
@@ -877,9 +889,9 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "1.0.21"
|
version = "1.0.22"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
|
checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "simd-adler32"
|
name = "simd-adler32"
|
||||||
@@ -898,9 +910,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smallvec"
|
name = "smallvec"
|
||||||
version = "1.13.1"
|
version = "1.13.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7"
|
checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "smithay-client-toolkit"
|
name = "smithay-client-toolkit"
|
||||||
@@ -908,7 +920,7 @@ version = "0.18.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a"
|
checksum = "922fd3eeab3bd820d76537ce8f582b1cf951eceb5475c28500c7457d9d17f53a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.5.0",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"calloop",
|
"calloop",
|
||||||
"calloop-wayland-source",
|
"calloop-wayland-source",
|
||||||
@@ -947,9 +959,9 @@ checksum = "9ac8fb7895b4afa060ad731a32860db8755da3449a47e796d5ecf758db2671d4"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.49"
|
version = "2.0.60"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "915aea9e586f80826ee59f8453c1101f9d1c4b3964cd2460185ee8e299ada496"
|
checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -958,18 +970,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.57"
|
version = "1.0.59"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b"
|
checksum = "f0126ad08bff79f29fc3ae6a55cc72352056dfff61e3ff8bb7129476d44b23aa"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.57"
|
version = "1.0.59"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81"
|
checksum = "d1cd413b5d558b4c5bf3680e324a6fa5014e7b7c067a51e69dbdf47eb7148b66"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1033,9 +1045,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.91"
|
version = "0.2.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f"
|
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"wasm-bindgen-macro",
|
"wasm-bindgen-macro",
|
||||||
@@ -1043,9 +1055,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-backend"
|
name = "wasm-bindgen-backend"
|
||||||
version = "0.2.91"
|
version = "0.2.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b"
|
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"log",
|
"log",
|
||||||
@@ -1058,9 +1070,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro"
|
name = "wasm-bindgen-macro"
|
||||||
version = "0.2.91"
|
version = "0.2.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed"
|
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"quote",
|
"quote",
|
||||||
"wasm-bindgen-macro-support",
|
"wasm-bindgen-macro-support",
|
||||||
@@ -1068,9 +1080,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-macro-support"
|
name = "wasm-bindgen-macro-support"
|
||||||
version = "0.2.91"
|
version = "0.2.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66"
|
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1081,9 +1093,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen-shared"
|
name = "wasm-bindgen-shared"
|
||||||
version = "0.2.91"
|
version = "0.2.92"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838"
|
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wayland-backend"
|
name = "wayland-backend"
|
||||||
@@ -1105,7 +1117,7 @@ version = "0.31.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "82fb96ee935c2cea6668ccb470fb7771f6215d1691746c2d896b447a00ad3f1f"
|
checksum = "82fb96ee935c2cea6668ccb470fb7771f6215d1691746c2d896b447a00ad3f1f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.5.0",
|
||||||
"rustix",
|
"rustix",
|
||||||
"wayland-backend",
|
"wayland-backend",
|
||||||
"wayland-scanner",
|
"wayland-scanner",
|
||||||
@@ -1117,7 +1129,7 @@ version = "0.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e"
|
checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.5.0",
|
||||||
"cursor-icon",
|
"cursor-icon",
|
||||||
"wayland-backend",
|
"wayland-backend",
|
||||||
]
|
]
|
||||||
@@ -1139,7 +1151,7 @@ version = "0.31.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4"
|
checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.5.0",
|
||||||
"wayland-backend",
|
"wayland-backend",
|
||||||
"wayland-client",
|
"wayland-client",
|
||||||
"wayland-scanner",
|
"wayland-scanner",
|
||||||
@@ -1151,7 +1163,7 @@ version = "0.2.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6"
|
checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.4.2",
|
"bitflags 2.5.0",
|
||||||
"wayland-backend",
|
"wayland-backend",
|
||||||
"wayland-client",
|
"wayland-client",
|
||||||
"wayland-protocols",
|
"wayland-protocols",
|
||||||
@@ -1243,13 +1255,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-targets"
|
name = "windows-targets"
|
||||||
version = "0.52.4"
|
version = "0.52.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b"
|
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc",
|
||||||
"windows_i686_gnu",
|
"windows_i686_gnu",
|
||||||
|
"windows_i686_gnullvm",
|
||||||
"windows_i686_msvc",
|
"windows_i686_msvc",
|
||||||
"windows_x86_64_gnu",
|
"windows_x86_64_gnu",
|
||||||
"windows_x86_64_gnullvm",
|
"windows_x86_64_gnullvm",
|
||||||
@@ -1258,45 +1271,51 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_gnullvm"
|
name = "windows_aarch64_gnullvm"
|
||||||
version = "0.52.4"
|
version = "0.52.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9"
|
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_msvc"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.52.4"
|
version = "0.52.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675"
|
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnu"
|
name = "windows_i686_gnu"
|
||||||
version = "0.52.4"
|
version = "0.52.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3"
|
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnullvm"
|
||||||
|
version = "0.52.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_msvc"
|
name = "windows_i686_msvc"
|
||||||
version = "0.52.4"
|
version = "0.52.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02"
|
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnu"
|
name = "windows_x86_64_gnu"
|
||||||
version = "0.52.4"
|
version = "0.52.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03"
|
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnullvm"
|
name = "windows_x86_64_gnullvm"
|
||||||
version = "0.52.4"
|
version = "0.52.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177"
|
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_msvc"
|
name = "windows_x86_64_msvc"
|
||||||
version = "0.52.4"
|
version = "0.52.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8"
|
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wio"
|
name = "wio"
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rten-tensor = "0.3.*"
|
rten-tensor = "0.8.0"
|
||||||
rten = "0.3.1"
|
rten = "0.8.0"
|
||||||
ocrs = "0.4.*"
|
ocrs = "0.6.0"
|
||||||
image = "0.24.9"
|
image = "0.24.9"
|
||||||
anyhow = "1.0.81"
|
anyhow = "1.0.81"
|
||||||
smithay-client-toolkit = "0.18.1"
|
smithay-client-toolkit = "0.18.1"
|
||||||
|
|||||||
@@ -5,51 +5,19 @@ use std::time::Instant;
|
|||||||
use rten_tensor::{NdTensor, AsView};
|
use rten_tensor::{NdTensor, AsView};
|
||||||
use rten::Model;
|
use rten::Model;
|
||||||
use ocrs::{OcrEngine, OcrEngineParams};
|
use ocrs::{OcrEngine, OcrEngineParams};
|
||||||
use image::{ColorType, ImageFormat};
|
|
||||||
|
|
||||||
const MATRIX_LEN: usize = 800;
|
pub fn print_words(image: NdTensor<f32, 3>) -> Result<(), Box<dyn Error>> {
|
||||||
const TEXT_MATRIX_RATIO: f64 = 0.5;
|
|
||||||
const LINE_WIDTH: f64 = 10.0;
|
|
||||||
|
|
||||||
const MATRIX_X_SIZE: f64 = MATRIX_LEN as f64;
|
|
||||||
const TEXT_X_SIZE: f64 = (MATRIX_X_SIZE as f64) * TEXT_MATRIX_RATIO;
|
|
||||||
const TEXT_X_OFFSET: f64 = (MATRIX_X_SIZE - TEXT_X_SIZE) / 2.0;
|
|
||||||
const LINE_WIDTH_X_OFFSET: f64 = LINE_WIDTH / 2.0;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Point {
|
|
||||||
pub x: f64,
|
|
||||||
pub y: f64,
|
|
||||||
pub new_line: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn print_words(points: &Vec<Point>) -> Result<(), Box<dyn Error>> {
|
|
||||||
|
|
||||||
let begin = Instant::now();
|
let begin = Instant::now();
|
||||||
let processed_data = process(points);
|
|
||||||
|
|
||||||
println!("{:#?}", begin.elapsed());
|
println!("{:#?}", begin.elapsed());
|
||||||
let begin = Instant::now();
|
let begin = Instant::now();
|
||||||
ocr(processed_data)?;
|
ocr(image).unwrap();
|
||||||
println!("{:#?}", begin.elapsed());
|
println!("{:#?}", begin.elapsed());
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process(points: &Vec<Point>) -> NdTensor<f32, 3> {
|
|
||||||
|
|
||||||
let matrix = to_matrix(points);
|
|
||||||
let y_len = matrix[0].len();
|
|
||||||
let x_len = matrix[0][0].len();
|
|
||||||
let image_data: Box<[u8]> = matrix.iter().flatten().flatten().map(|f| if *f > 0.5 { u8::from(0) } else { u8::from(255) }).collect();
|
|
||||||
let data: Vec<f32> = matrix.into_iter().flatten().flatten().map(|f| f as f32).collect();
|
|
||||||
|
|
||||||
image::save_buffer_with_format("./image.png", &image_data, x_len as u32, y_len as u32, ColorType::L8, ImageFormat::Png).unwrap();
|
|
||||||
|
|
||||||
|
|
||||||
NdTensor::from_data([1, y_len, x_len], data)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn ocr(data: NdTensor<f32, 3>) -> Result<(), Box<dyn Error>> {
|
fn ocr(data: NdTensor<f32, 3>) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
let detection_model_data = fs::read("text-detection.rten")?;
|
let detection_model_data = fs::read("text-detection.rten")?;
|
||||||
@@ -58,7 +26,6 @@ fn ocr(data: NdTensor<f32, 3>) -> Result<(), Box<dyn Error>> {
|
|||||||
let detection_model = Model::load(&detection_model_data)?;
|
let detection_model = Model::load(&detection_model_data)?;
|
||||||
let rec_model = Model::load(&rec_model_data)?;
|
let rec_model = Model::load(&rec_model_data)?;
|
||||||
|
|
||||||
|
|
||||||
let ocr_engine = OcrEngine::new(OcrEngineParams {
|
let ocr_engine = OcrEngine::new(OcrEngineParams {
|
||||||
detection_model: Some(detection_model),
|
detection_model: Some(detection_model),
|
||||||
recognition_model: Some(rec_model),
|
recognition_model: Some(rec_model),
|
||||||
@@ -87,91 +54,3 @@ fn ocr(data: NdTensor<f32, 3>) -> Result<(), Box<dyn Error>> {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn line(x: f64, point1: (f64, f64), point2: (f64, f64)) -> f64 {
|
|
||||||
let slope = (point2.1 - point1.1) / (point2.0 - point1.0);
|
|
||||||
|
|
||||||
let point = slope * (x - point1.0) + point1.1;
|
|
||||||
|
|
||||||
point
|
|
||||||
}
|
|
||||||
|
|
||||||
fn to_matrix(points: &Vec<Point>) -> Vec<Vec<Vec<f64>>> {
|
|
||||||
|
|
||||||
let min_x = points.iter().min_by_key(|p| p.x as i32).unwrap().x;
|
|
||||||
let min_y = points.iter().min_by_key(|p| p.y as i32).unwrap().y;
|
|
||||||
let max_x = points.iter().max_by_key(|p| p.x as i32).unwrap().x;
|
|
||||||
let max_y = points.iter().max_by_key(|p| p.y as i32).unwrap().y;
|
|
||||||
|
|
||||||
let x_len = max_x - min_x;
|
|
||||||
let y_len = max_y - min_y;
|
|
||||||
|
|
||||||
let y_ratio = y_len / x_len;
|
|
||||||
|
|
||||||
let matrix_y_size = MATRIX_X_SIZE * y_ratio;
|
|
||||||
let text_y_size = TEXT_X_SIZE * y_ratio;
|
|
||||||
let text_y_offset = TEXT_X_OFFSET * y_ratio;
|
|
||||||
let line_width_y_offset = LINE_WIDTH_X_OFFSET * y_ratio;
|
|
||||||
|
|
||||||
let x_scale = MATRIX_X_SIZE / x_len;
|
|
||||||
let y_scale = matrix_y_size / y_len;
|
|
||||||
|
|
||||||
|
|
||||||
let mut matrix: Vec<Vec<f64>> = vec![
|
|
||||||
vec![0.0; MATRIX_LEN]; (matrix_y_size as usize) + 1
|
|
||||||
];
|
|
||||||
|
|
||||||
let scaled_points: Vec<((f64, f64), bool)> = points
|
|
||||||
.iter()
|
|
||||||
.map(|point| {
|
|
||||||
let x_scaled = ((point.x - min_x) * x_scale) + TEXT_X_OFFSET;
|
|
||||||
let y_scaled = ((point.y - min_y) * y_scale) + text_y_offset;
|
|
||||||
|
|
||||||
((x_scaled, y_scaled), point.new_line)
|
|
||||||
}).collect();
|
|
||||||
|
|
||||||
let mut last_x = 0.0;
|
|
||||||
let mut last_y = 0.0;
|
|
||||||
|
|
||||||
for ((current_x, current_y), newline) in scaled_points {
|
|
||||||
|
|
||||||
if !newline {
|
|
||||||
let curr_x_start = current_x - LINE_WIDTH_X_OFFSET;
|
|
||||||
let curr_x_end = current_x + LINE_WIDTH_X_OFFSET;
|
|
||||||
|
|
||||||
let last_x_start = last_x - LINE_WIDTH_X_OFFSET;
|
|
||||||
let last_x_end = last_x + LINE_WIDTH_X_OFFSET;
|
|
||||||
|
|
||||||
let top_y = current_y.max(last_y) + line_width_y_offset;
|
|
||||||
let bottom_y = current_y.min(last_y) - line_width_y_offset;
|
|
||||||
|
|
||||||
let start_x = (last_x_start.min(curr_x_start)) as usize;
|
|
||||||
let end_x = (last_x_end.max(curr_x_end)) as usize + 1;
|
|
||||||
|
|
||||||
|
|
||||||
for x in start_x..(end_x + 1) {
|
|
||||||
|
|
||||||
let left_line_y = line(x as f64, (last_x_start, last_y), (curr_x_start, current_y));
|
|
||||||
let right_line_y = line(x as f64, (last_x_end, last_y), (curr_x_end, current_x));
|
|
||||||
|
|
||||||
let top_line_y = left_line_y
|
|
||||||
.max(right_line_y)
|
|
||||||
.min(top_y) as usize;
|
|
||||||
let bottom_line_y = left_line_y
|
|
||||||
.min(right_line_y)
|
|
||||||
.max(bottom_y) as usize;
|
|
||||||
|
|
||||||
for y in bottom_line_y..(top_line_y + 1) {
|
|
||||||
matrix[y][x] = 1.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
last_x = current_x;
|
|
||||||
last_y = current_y;
|
|
||||||
}
|
|
||||||
|
|
||||||
vec![matrix]
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
mod ui;
|
|
||||||
pub mod app;
|
pub mod app;
|
||||||
mod draw;
|
pub mod draw;
|
||||||
|
mod ui;
|
||||||
mod builder;
|
mod builder;
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
|||||||
@@ -32,17 +32,21 @@ use wayland_client::{
|
|||||||
|
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use rten_tensor::NdTensor;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use crate::wayland::{
|
use crate::wayland::{
|
||||||
draw::DrawPath,
|
draw::{DrawPath, Draw},
|
||||||
builder::{TextAreaBuilder, DrawAreaBuilder, ButtonBuilder},
|
builder::{TextAreaBuilder, DrawAreaBuilder, ButtonBuilder},
|
||||||
ui::{self, Widget},
|
ui::{self, Widget, ButtonType},
|
||||||
Position,
|
Position,
|
||||||
};
|
};
|
||||||
|
|
||||||
const WINDOW_HEIGHT: u32 = 256;
|
use crate::process_point::print_words;
|
||||||
const WINDOW_WIDTH: u32 = 512;
|
|
||||||
|
const WINDOW_HEIGHT: usize = 256;
|
||||||
|
const WINDOW_WIDTH: usize = 512;
|
||||||
|
|
||||||
pub(crate) struct SimpleWindow {
|
pub(crate) struct SimpleWindow {
|
||||||
registry_state: RegistryState,
|
registry_state: RegistryState,
|
||||||
@@ -55,8 +59,8 @@ pub(crate) struct SimpleWindow {
|
|||||||
pool: SlotPool,
|
pool: SlotPool,
|
||||||
window: Window,
|
window: Window,
|
||||||
ui: Option<ui::Window>,
|
ui: Option<ui::Window>,
|
||||||
width: u32,
|
width: usize,
|
||||||
height: u32,
|
height: usize,
|
||||||
cursor_down: bool,
|
cursor_down: bool,
|
||||||
exit: bool,
|
exit: bool,
|
||||||
first_configure: bool,
|
first_configure: bool,
|
||||||
@@ -87,8 +91,8 @@ impl SimpleWindow {
|
|||||||
|
|
||||||
window.set_title("A window");
|
window.set_title("A window");
|
||||||
window.set_app_id("simmer.simplewindow");
|
window.set_app_id("simmer.simplewindow");
|
||||||
window.set_min_size(Some((WINDOW_WIDTH, WINDOW_HEIGHT)));
|
window.set_min_size(Some((WINDOW_WIDTH as u32, WINDOW_HEIGHT as u32)));
|
||||||
window.set_max_size(Some((WINDOW_WIDTH, WINDOW_HEIGHT)));
|
window.set_max_size(Some((WINDOW_WIDTH as u32, WINDOW_HEIGHT as u32)));
|
||||||
|
|
||||||
window.commit();
|
window.commit();
|
||||||
|
|
||||||
@@ -260,8 +264,8 @@ impl WindowHandler for SimpleWindow {
|
|||||||
let mut draw_area = DrawAreaBuilder::new();
|
let mut draw_area = DrawAreaBuilder::new();
|
||||||
|
|
||||||
draw_area.position(0.0, 50.0);
|
draw_area.position(0.0, 50.0);
|
||||||
draw_area.width(self.width as f32 - 100.0);
|
draw_area.width(self.width - 100);
|
||||||
draw_area.height(self.height as f32 - 50.0);
|
draw_area.height(self.height - 50);
|
||||||
draw_area.path(&mut self.draw_path);
|
draw_area.path(&mut self.draw_path);
|
||||||
|
|
||||||
let draw_area = draw_area.finish();
|
let draw_area = draw_area.finish();
|
||||||
@@ -273,22 +277,31 @@ impl WindowHandler for SimpleWindow {
|
|||||||
draw_area,
|
draw_area,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut button = ButtonBuilder::new();
|
let mut enter_button = ButtonBuilder::new();
|
||||||
|
|
||||||
button.position(self.width as f32 - 100.0, 50.0);
|
enter_button.button_type(ButtonType::Enter);
|
||||||
button.width(100.0);
|
enter_button.position(self.width - 100, 60);
|
||||||
button.height(50.0);
|
enter_button.width(100);
|
||||||
let button = button.finish();
|
enter_button.height(50);
|
||||||
|
let enter_button = enter_button.finish();
|
||||||
|
|
||||||
|
let mut clear_button = ButtonBuilder::new();
|
||||||
|
|
||||||
|
clear_button.button_type(ButtonType::Clear);
|
||||||
|
clear_button.position(self.width - 100, 120);
|
||||||
|
clear_button.width(100);
|
||||||
|
clear_button.height(50);
|
||||||
|
let clear_button = clear_button.finish();
|
||||||
|
|
||||||
let mut text_area = TextAreaBuilder::new();
|
let mut text_area = TextAreaBuilder::new();
|
||||||
text_area.position(0.0, 0.0);
|
text_area.position(0.0, 0.0);
|
||||||
text_area.width(self.width as f32);
|
text_area.width(self.width);
|
||||||
text_area.height(50.0);
|
text_area.height(50);
|
||||||
let text_area = text_area.finish();
|
let text_area = text_area.finish();
|
||||||
|
|
||||||
|
|
||||||
window.add_widget(button);
|
window.add_widget(enter_button);
|
||||||
|
window.add_widget(clear_button);
|
||||||
window.add_widget(text_area);
|
window.add_widget(text_area);
|
||||||
|
|
||||||
self.ui = Some(window);
|
self.ui = Some(window);
|
||||||
@@ -354,11 +367,24 @@ impl PointerHandler for SimpleWindow {
|
|||||||
window.draw_area.path.add_point(pos, true);
|
window.draw_area.path.add_point(pos, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for widget in &window.widgets {
|
for button in window.widgets
|
||||||
|
.iter()
|
||||||
|
.filter_map(|widget| {
|
||||||
if let Widget::Button(button) = widget {
|
if let Widget::Button(button) = widget {
|
||||||
if button.contains_point(pos) {
|
Some(button)
|
||||||
window.draw_area.path = DrawPath::default();
|
} else {
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
{
|
||||||
|
match button.button_type {
|
||||||
|
ButtonType::Clear if button.contains_point(pos) => {
|
||||||
|
window.draw_area.path = DrawPath::default();
|
||||||
|
},
|
||||||
|
ButtonType::Enter if button.contains_point(pos) => {
|
||||||
|
print_words((&window.draw_area).into()).unwrap()
|
||||||
|
},
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::wayland::{
|
use crate::wayland::{
|
||||||
ui::{TextArea, TextAreaColors, Button, ButtonColors, Widget},
|
ui::{TextArea, TextAreaColors, Button, ButtonColors, Widget, ButtonType},
|
||||||
draw::{DrawAreaColors, DrawArea, DrawPath},
|
draw::{DrawAreaColors, DrawArea, DrawPath},
|
||||||
Position
|
Position
|
||||||
};
|
};
|
||||||
@@ -7,8 +7,8 @@ use crate::wayland::{
|
|||||||
use raqote::{DrawOptions, PathBuilder};
|
use raqote::{DrawOptions, PathBuilder};
|
||||||
|
|
||||||
pub(super) struct TextAreaBuilder {
|
pub(super) struct TextAreaBuilder {
|
||||||
pub(super) width: Option<f32>,
|
pub(super) width: Option<usize>,
|
||||||
pub(super) height: Option<f32>,
|
pub(super) height: Option<usize>,
|
||||||
pub(super) position: Option<Position>,
|
pub(super) position: Option<Position>,
|
||||||
pub(super) colors: Option<TextAreaColors>,
|
pub(super) colors: Option<TextAreaColors>,
|
||||||
pub(super) options: Option<DrawOptions>,
|
pub(super) options: Option<DrawOptions>,
|
||||||
@@ -25,11 +25,11 @@ impl<'a> TextAreaBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn width(&mut self, width: f32) {
|
pub(super) fn width(&mut self, width: usize) {
|
||||||
self.width = Some(width)
|
self.width = Some(width)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn height(&mut self, height: f32) {
|
pub(super) fn height(&mut self, height: usize) {
|
||||||
self.height = Some(height)
|
self.height = Some(height)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,11 +56,12 @@ impl<'a> TextAreaBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(super) struct ButtonBuilder {
|
pub(super) struct ButtonBuilder {
|
||||||
pub(super) width: Option<f32>,
|
pub(super) width: Option<usize>,
|
||||||
pub(super) height: Option<f32>,
|
pub(super) height: Option<usize>,
|
||||||
pub(super) position: Option<Position>,
|
pub(super) position: Option<Position>,
|
||||||
pub(super) colors: Option<ButtonColors>,
|
pub(super) colors: Option<ButtonColors>,
|
||||||
pub(super) options: Option<DrawOptions>,
|
pub(super) options: Option<DrawOptions>,
|
||||||
|
pub(super) button_type: Option<ButtonType>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ButtonBuilder {
|
impl ButtonBuilder {
|
||||||
@@ -71,25 +72,30 @@ impl ButtonBuilder {
|
|||||||
position: None,
|
position: None,
|
||||||
colors: None,
|
colors: None,
|
||||||
options: None,
|
options: None,
|
||||||
|
button_type: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn width(&mut self, width: f32) {
|
pub(super) fn width(&mut self, width: usize) {
|
||||||
self.width = Some(width)
|
self.width = Some(width)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn height(&mut self, height: f32) {
|
pub(super) fn height(&mut self, height: usize) {
|
||||||
self.height = Some(height)
|
self.height = Some(height)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn position(&mut self, x: f32, y: f32) {
|
pub(super) fn position(&mut self, x: usize, y: usize) {
|
||||||
self.position = Some(Position::new(x, y))
|
self.position = Some(Position::new(x as f32, y as f32))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn colors(&mut self, colors: ButtonColors) {
|
pub(super) fn colors(&mut self, colors: ButtonColors) {
|
||||||
self.colors = Some(colors)
|
self.colors = Some(colors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) fn button_type(&mut self, button_type: ButtonType) {
|
||||||
|
self.button_type = Some(button_type)
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn finish(self) -> Widget {
|
pub(super) fn finish(self) -> Widget {
|
||||||
let width = self.width.expect("Button must have a width");
|
let width = self.width.expect("Button must have a width");
|
||||||
let height = self.height.expect("Button must have a height");
|
let height = self.height.expect("Button must have a height");
|
||||||
@@ -97,14 +103,15 @@ impl ButtonBuilder {
|
|||||||
|
|
||||||
let mut button_path = PathBuilder::new();
|
let mut button_path = PathBuilder::new();
|
||||||
button_path.move_to(position.x, position.y);
|
button_path.move_to(position.x, position.y);
|
||||||
button_path.line_to(position.x + width, position.y);
|
button_path.line_to(position.x + width as f32, position.y);
|
||||||
button_path.line_to(position.x + width, position.y + height);
|
button_path.line_to(position.x + width as f32, position.y + height as f32);
|
||||||
button_path.line_to(position.x, position.y + height);
|
button_path.line_to(position.x, position.y + height as f32);
|
||||||
button_path.line_to(position.x, position.y);
|
button_path.line_to(position.x, position.y);
|
||||||
let button_path = button_path.finish();
|
let button_path = button_path.finish();
|
||||||
|
|
||||||
Widget::Button(
|
Widget::Button(
|
||||||
Button {
|
Button {
|
||||||
|
button_type: self.button_type.expect("Button must have a type"),
|
||||||
width: self.width.expect("Button must have width"),
|
width: self.width.expect("Button must have width"),
|
||||||
height: self.height.expect("Button must have height"),
|
height: self.height.expect("Button must have height"),
|
||||||
position: self.position.expect("Button must have a position"),
|
position: self.position.expect("Button must have a position"),
|
||||||
@@ -117,8 +124,8 @@ impl ButtonBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(super) struct DrawAreaBuilder {
|
pub(super) struct DrawAreaBuilder {
|
||||||
pub(super) width: Option<f32>,
|
pub(super) width: Option<usize>,
|
||||||
pub(super) height: Option<f32>,
|
pub(super) height: Option<usize>,
|
||||||
pub(super) position: Option<Position>,
|
pub(super) position: Option<Position>,
|
||||||
pub(super) path: Option<DrawPath>,
|
pub(super) path: Option<DrawPath>,
|
||||||
pub(super) colors: Option<DrawAreaColors>,
|
pub(super) colors: Option<DrawAreaColors>,
|
||||||
@@ -137,11 +144,11 @@ impl DrawAreaBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn width(&mut self, width: f32) {
|
pub(super) fn width(&mut self, width: usize) {
|
||||||
self.width = Some(width)
|
self.width = Some(width)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn height(&mut self, height: f32) {
|
pub(super) fn height(&mut self, height: usize) {
|
||||||
self.height = Some(height)
|
self.height = Some(height)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,9 +175,9 @@ impl DrawAreaBuilder {
|
|||||||
|
|
||||||
let mut draw_rect_path = PathBuilder::new();
|
let mut draw_rect_path = PathBuilder::new();
|
||||||
draw_rect_path.move_to(position.x, position.y);
|
draw_rect_path.move_to(position.x, position.y);
|
||||||
draw_rect_path.line_to(position.x + width, position.y);
|
draw_rect_path.line_to(position.x + width as f32, position.y);
|
||||||
draw_rect_path.line_to(position.x + width, position.y + height);
|
draw_rect_path.line_to(position.x + width as f32, position.y + height as f32);
|
||||||
draw_rect_path.line_to(position.x, position.y + height);
|
draw_rect_path.line_to(position.x, position.y + height as f32);
|
||||||
draw_rect_path.line_to(position.x, position.y);
|
draw_rect_path.line_to(position.x, position.y);
|
||||||
let draw_rect_path = draw_rect_path.finish();
|
let draw_rect_path = draw_rect_path.finish();
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
use raqote::{DrawTarget, Color, StrokeStyle, PathBuilder, Source, DrawOptions};
|
use raqote::{DrawTarget, Color, StrokeStyle, PathBuilder, Source, DrawOptions, SolidSource};
|
||||||
|
use rten_tensor::NdTensor;
|
||||||
|
|
||||||
use crate::wayland::Position;
|
use crate::wayland::Position;
|
||||||
|
use crate::process_point::print_words;
|
||||||
|
|
||||||
pub(super) trait Draw {
|
pub(super) trait Draw {
|
||||||
fn render(&self, area: &mut DrawTarget<&mut [u32]>);
|
fn render(&self, area: &mut DrawTarget<&mut [u32]>);
|
||||||
@@ -9,20 +11,20 @@ pub(super) trait Draw {
|
|||||||
type Path = Vec<Position>;
|
type Path = Vec<Position>;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub(super) struct DrawPath {
|
pub(crate) struct DrawPath {
|
||||||
pub(super) paths: Vec<Path>,
|
pub(crate) paths: Vec<Path>,
|
||||||
pub(super) newline: bool,
|
pub(crate) newline: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DrawPath {
|
impl DrawPath {
|
||||||
pub(super) fn new() -> Self {
|
pub(crate) fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
paths: Vec::new(),
|
paths: Vec::new(),
|
||||||
newline: false,
|
newline: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn add_point(&mut self, point: Position, newline: bool) {
|
pub(crate) fn add_point(&mut self, point: Position, newline: bool) {
|
||||||
if newline {
|
if newline {
|
||||||
self.paths.push(vec![point])
|
self.paths.push(vec![point])
|
||||||
} else if self.paths.len() > 0 {
|
} else if self.paths.len() > 0 {
|
||||||
@@ -33,15 +35,15 @@ impl DrawPath {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn into_iter(self) -> std::vec::IntoIter<Path> {
|
pub(crate) fn into_iter(self) -> std::vec::IntoIter<Path> {
|
||||||
self.paths.into_iter()
|
self.paths.into_iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn iter(&self) -> std::slice::Iter<Path> {
|
pub(crate) fn iter(&self) -> std::slice::Iter<Path> {
|
||||||
self.paths.iter()
|
self.paths.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) fn iter_mut(&mut self) -> std::slice::IterMut<Path> {
|
pub(crate) fn iter_mut(&mut self) -> std::slice::IterMut<Path> {
|
||||||
self.paths.iter_mut()
|
self.paths.iter_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,8 +65,8 @@ impl Default for DrawAreaColors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(super) struct DrawArea {
|
pub(super) struct DrawArea {
|
||||||
pub(super) width: f32,
|
pub(super) width: usize,
|
||||||
pub(super) height: f32,
|
pub(super) height: usize,
|
||||||
pub(super) position: Position,
|
pub(super) position: Position,
|
||||||
pub(super) path: DrawPath,
|
pub(super) path: DrawPath,
|
||||||
pub(super) shape: raqote::Path,
|
pub(super) shape: raqote::Path,
|
||||||
@@ -89,6 +91,78 @@ impl DrawArea {
|
|||||||
self.shape.contains_point(0.1, point.x, point.y)
|
self.shape.contains_point(0.1, point.x, point.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<&DrawArea> for NdTensor<f32, 3> {
|
||||||
|
fn from(draw_area: &DrawArea) -> Self {
|
||||||
|
let mut target = DrawTarget::new(draw_area.width as i32, draw_area.height as i32);
|
||||||
|
|
||||||
|
target.fill_rect(
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
draw_area.width as f32,
|
||||||
|
draw_area.height as f32,
|
||||||
|
&Source::Solid(SolidSource::from_unpremultiplied_argb(0xff, 0xff, 0xff, 0xff)),
|
||||||
|
&DrawOptions::new(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut draw_path = PathBuilder::new();
|
||||||
|
|
||||||
|
for path in draw_area.path.iter() {
|
||||||
|
if path.len() > 1 {
|
||||||
|
let mut path = path
|
||||||
|
.into_iter()
|
||||||
|
.map(|position| Position::new(position.x - draw_area.position.x, position.y - draw_area.position.y));
|
||||||
|
|
||||||
|
let first_point = path
|
||||||
|
.by_ref()
|
||||||
|
.next();
|
||||||
|
|
||||||
|
if let Some(point) = first_point {
|
||||||
|
draw_path.move_to(point.x, point.y);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
for point in path {
|
||||||
|
draw_path.line_to(point.x, point.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
let draw_path = draw_path.finish();
|
||||||
|
|
||||||
|
target.stroke(
|
||||||
|
&draw_path,
|
||||||
|
&Source::Solid(SolidSource::from_unpremultiplied_argb(0xff, 0x00, 0x00, 0x00)),
|
||||||
|
&StrokeStyle {width: 3.0, ..StrokeStyle::default()},
|
||||||
|
&DrawOptions::new(),
|
||||||
|
);
|
||||||
|
|
||||||
|
let data: Vec<f32> = target
|
||||||
|
.get_data_u8()
|
||||||
|
.chunks(4)
|
||||||
|
.into_iter()
|
||||||
|
.map(|chunk| chunk[0..3].into_iter().map(|byte| *byte as f32).sum::<f32>() / 765.0)
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
image::save_buffer_with_format(
|
||||||
|
"./image.png",
|
||||||
|
&data
|
||||||
|
.iter()
|
||||||
|
.map(|num| (num * 255.0).floor() as u8)
|
||||||
|
.collect::<Vec<u8>>(),
|
||||||
|
draw_area.width as u32,
|
||||||
|
draw_area.height as u32,
|
||||||
|
image::ColorType::L8,
|
||||||
|
image::ImageFormat::Png
|
||||||
|
).unwrap();
|
||||||
|
|
||||||
|
NdTensor::from_data([1, draw_area.width as usize, draw_area.height as usize], data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Draw for DrawArea {
|
impl Draw for DrawArea {
|
||||||
|
|||||||
@@ -103,9 +103,16 @@ impl Default for ButtonColors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq, Eq)]
|
||||||
|
pub(super) enum ButtonType {
|
||||||
|
Clear,
|
||||||
|
Enter,
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) struct Button {
|
pub(super) struct Button {
|
||||||
pub(super) width: f32,
|
pub(super) button_type: ButtonType,
|
||||||
pub(super) height: f32,
|
pub(super) width: usize,
|
||||||
|
pub(super) height: usize,
|
||||||
pub(super) position: Position,
|
pub(super) position: Position,
|
||||||
pub(super) shape: raqote::Path,
|
pub(super) shape: raqote::Path,
|
||||||
pub(super) colors: ButtonColors,
|
pub(super) colors: ButtonColors,
|
||||||
@@ -149,8 +156,8 @@ impl Default for TextAreaColors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(super) struct TextArea {
|
pub(super) struct TextArea {
|
||||||
pub(super) width: f32,
|
pub(super) width: usize,
|
||||||
pub(super) height: f32,
|
pub(super) height: usize,
|
||||||
pub(super) position: Position,
|
pub(super) position: Position,
|
||||||
pub(super) colors: TextAreaColors,
|
pub(super) colors: TextAreaColors,
|
||||||
pub(super) options: DrawOptions,
|
pub(super) options: DrawOptions,
|
||||||
@@ -172,8 +179,8 @@ impl Draw for TextArea {
|
|||||||
area.fill_rect(
|
area.fill_rect(
|
||||||
self.position.x,
|
self.position.x,
|
||||||
self.position.y,
|
self.position.y,
|
||||||
self.width,
|
self.width as f32,
|
||||||
self.height,
|
self.height as f32,
|
||||||
&self.background_source(),
|
&self.background_source(),
|
||||||
&self.options,
|
&self.options,
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user