Rework camera handling

This commit is contained in:
Jack Grigg 2024-12-12 04:45:09 +00:00
parent ba7b0a1504
commit c532ea0fc8
3 changed files with 538 additions and 29 deletions

478
Cargo.lock generated
View File

@ -117,6 +117,12 @@ dependencies = [
"memchr",
]
[[package]]
name = "aligned-vec"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1"
[[package]]
name = "allocator-api2"
version = "0.2.21"
@ -188,12 +194,29 @@ version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7"
[[package]]
name = "arbitrary"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223"
[[package]]
name = "arc-swap"
version = "1.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69f7f8c3906b62b754cd5326047894316021dcfe5a194c8ea52bdd94934a3457"
[[package]]
name = "arg_enum_proc_macro"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.90",
]
[[package]]
name = "arrayref"
version = "0.3.9"
@ -369,6 +392,29 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]]
name = "av1-grain"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6678909d8c5d46a42abcf571271e15fdbc0a225e3646cf23762cd415046c78bf"
dependencies = [
"anyhow",
"arrayvec",
"log",
"nom",
"num-rational",
"v_frame",
]
[[package]]
name = "avif-serialize"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e335041290c43101ca215eed6f43ec437eb5a42125573f600fc3fa42b9bddd62"
dependencies = [
"arrayvec",
]
[[package]]
name = "axum"
version = "0.7.9"
@ -547,6 +593,12 @@ dependencies = [
"zeroize",
]
[[package]]
name = "bit_field"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
[[package]]
name = "bitcoin-private"
version = "0.1.0"
@ -574,6 +626,12 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "bitstream-io"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2"
[[package]]
name = "bitvec"
version = "1.0.1"
@ -686,6 +744,12 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "built"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c360505aed52b7ec96a3636c3f039d99103c37d1d9b4f7a8c743d3ea9ffcd03b"
[[package]]
name = "bumpalo"
version = "3.16.0"
@ -794,6 +858,16 @@ dependencies = [
"nom",
]
[[package]]
name = "cfg-expr"
version = "0.15.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b40ccee03b5175c18cde8f37e7d2a33bcef6f8ec8f7cc0d81090d1bb380949c9"
dependencies = [
"smallvec",
"target-lexicon",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
@ -919,6 +993,12 @@ dependencies = [
"objc",
]
[[package]]
name = "color_quant"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
[[package]]
name = "compact_str"
version = "0.8.0"
@ -1351,7 +1431,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72f9bc3564f74be6c35d49a7efee54380d7946ccc631323067f33fabb9246027"
dependencies = [
"derive-deftly-macros",
"heck",
"heck 0.5.0",
]
[[package]]
@ -1360,9 +1440,9 @@ version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1b84d32b18d9a256d81e4fec2e4cfd0ab6dde5e5ff49be1713ae0adbd0060c2"
dependencies = [
"heck",
"heck 0.5.0",
"indexmap 2.7.0",
"itertools",
"itertools 0.13.0",
"proc-macro-crate",
"proc-macro2",
"quote",
@ -1670,6 +1750,21 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "exr"
version = "1.73.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0"
dependencies = [
"bit_field",
"half",
"lebe",
"miniz_oxide",
"rayon-core",
"smallvec",
"zune-inflate",
]
[[package]]
name = "f4jumble"
version = "0.1.0"
@ -1696,6 +1791,15 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
[[package]]
name = "fdeflate"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c"
dependencies = [
"simd-adler32",
]
[[package]]
name = "ff"
version = "0.13.0"
@ -2071,6 +2175,16 @@ dependencies = [
"syn 2.0.90",
]
[[package]]
name = "gif"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2"
dependencies = [
"color_quant",
"weezl",
]
[[package]]
name = "gimli"
version = "0.31.1"
@ -2140,6 +2254,16 @@ dependencies = [
"tracing",
]
[[package]]
name = "half"
version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888"
dependencies = [
"cfg-if 1.0.0",
"crunchy",
]
[[package]]
name = "halo2_gadgets"
version = "0.3.0"
@ -2241,6 +2365,12 @@ dependencies = [
"stable_deref_trait",
]
[[package]]
name = "heck"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "heck"
version = "0.5.0"
@ -2513,9 +2643,37 @@ checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b"
dependencies = [
"bytemuck",
"byteorder-lite",
"color_quant",
"exr",
"gif",
"image-webp",
"num-traits",
"png",
"qoi",
"ravif",
"rayon",
"rgb",
"tiff",
"zune-core",
"zune-jpeg",
]
[[package]]
name = "image-webp"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e031e8e3d94711a9ccb5d6ea357439ef3dcbed361798bd4071dc4d9793fbe22f"
dependencies = [
"byteorder-lite",
"quick-error",
]
[[package]]
name = "imgref"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408"
[[package]]
name = "incrementalmerkletree"
version = "0.7.0"
@ -2596,6 +2754,17 @@ dependencies = [
"syn 2.0.90",
]
[[package]]
name = "interpolate_name"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.90",
]
[[package]]
name = "intl-memoizer"
version = "0.5.2"
@ -2648,6 +2817,15 @@ dependencies = [
"serde",
]
[[package]]
name = "itertools"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
dependencies = [
"either",
]
[[package]]
name = "itertools"
version = "0.13.0"
@ -2672,6 +2850,12 @@ dependencies = [
"libc",
]
[[package]]
name = "jpeg-decoder"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0"
[[package]]
name = "js-sys"
version = "0.3.76"
@ -2761,12 +2945,28 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "lebe"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
[[package]]
name = "libc"
version = "0.2.168"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5aaeb2981e0606ca11d79718f8bb01164f1d6ed75080182d3abf017e6d244b6d"
[[package]]
name = "libfuzzer-sys"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b9569d2f74e257076d8c6bfa73fb505b46b851e51ddaecc825944aa3bed17fa"
dependencies = [
"arbitrary",
"cc",
]
[[package]]
name = "libloading"
version = "0.8.6"
@ -2833,6 +3033,15 @@ version = "0.4.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
[[package]]
name = "loop9"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062"
dependencies = [
"imgref",
]
[[package]]
name = "lru"
version = "0.12.5"
@ -2977,6 +3186,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2d80299ef12ff69b16a84bb182e3b9df68b5a91574d3d4fa6e41b65deec4df1"
dependencies = [
"adler2",
"simd-adler32",
]
[[package]]
@ -3052,6 +3262,12 @@ dependencies = [
"jobserver",
]
[[package]]
name = "new_debug_unreachable"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54"
[[package]]
name = "nokhwa"
version = "0.10.7"
@ -3134,6 +3350,12 @@ version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9e591e719385e6ebaeb5ce5d3887f7d5676fceca6411d1925ccc95745f3d6f7"
[[package]]
name = "noop_proc_macro"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8"
[[package]]
name = "notify"
version = "6.1.1"
@ -3194,6 +3416,17 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
[[package]]
name = "num-derive"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.90",
]
[[package]]
name = "num-integer"
version = "0.1.46"
@ -3214,6 +3447,17 @@ dependencies = [
"num-traits",
]
[[package]]
name = "num-rational"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
dependencies = [
"num-bigint",
"num-integer",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.19"
@ -3632,6 +3876,19 @@ version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
[[package]]
name = "png"
version = "0.17.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67582bd5b65bdff614270e2ea89a1cf15bef71245cc1e5f7ea126977144211d"
dependencies = [
"bitflags 1.3.2",
"crc32fast",
"fdeflate",
"flate2",
"miniz_oxide",
]
[[package]]
name = "poly1305"
version = "0.8.0"
@ -3766,6 +4023,25 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "profiling"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d"
dependencies = [
"profiling-procmacros",
]
[[package]]
name = "profiling-procmacros"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30"
dependencies = [
"quote",
"syn 2.0.90",
]
[[package]]
name = "prost"
version = "0.13.4"
@ -3782,8 +4058,8 @@ version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0f3e5beed80eb580c68e2c600937ac2c4eedabdfd5ef1e5b7ea4f3fba84497b"
dependencies = [
"heck",
"itertools",
"heck 0.5.0",
"itertools 0.13.0",
"log",
"multimap",
"once_cell",
@ -3803,7 +4079,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3"
dependencies = [
"anyhow",
"itertools",
"itertools 0.13.0",
"proc-macro2",
"quote",
"syn 2.0.90",
@ -3850,12 +4126,27 @@ dependencies = [
"thiserror 1.0.69",
]
[[package]]
name = "qoi"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001"
dependencies = [
"bytemuck",
]
[[package]]
name = "qrcode"
version = "0.14.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d68782463e408eb1e668cf6152704bd856c78c5b6417adaee3203d8f4c1fc9ec"
[[package]]
name = "quick-error"
version = "2.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3"
[[package]]
name = "quote"
version = "1.0.37"
@ -3922,7 +4213,7 @@ dependencies = [
"crossterm",
"indoc",
"instability",
"itertools",
"itertools 0.13.0",
"lru",
"paste",
"strum",
@ -3931,6 +4222,56 @@ dependencies = [
"unicode-width 0.2.0",
]
[[package]]
name = "rav1e"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9"
dependencies = [
"arbitrary",
"arg_enum_proc_macro",
"arrayvec",
"av1-grain",
"bitstream-io",
"built",
"cfg-if 1.0.0",
"interpolate_name",
"itertools 0.12.1",
"libc",
"libfuzzer-sys",
"log",
"maybe-rayon",
"new_debug_unreachable",
"noop_proc_macro",
"num-derive",
"num-traits",
"once_cell",
"paste",
"profiling",
"rand",
"rand_chacha",
"simd_helpers",
"system-deps",
"thiserror 1.0.69",
"v_frame",
"wasm-bindgen",
]
[[package]]
name = "ravif"
version = "0.11.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2413fd96bd0ea5cdeeb37eaf446a22e6ed7b981d792828721e74ded1980a45c6"
dependencies = [
"avif-serialize",
"imgref",
"loop9",
"quick-error",
"rav1e",
"rayon",
"rgb",
]
[[package]]
name = "rayon"
version = "1.10.0"
@ -4764,6 +5105,21 @@ dependencies = [
"rand_core",
]
[[package]]
name = "simd-adler32"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
[[package]]
name = "simd_helpers"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6"
dependencies = [
"quote",
]
[[package]]
name = "simdutf8"
version = "0.1.5"
@ -4927,7 +5283,7 @@ version = "0.26.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be"
dependencies = [
"heck",
"heck 0.5.0",
"proc-macro2",
"quote",
"rustversion",
@ -4968,12 +5324,31 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
[[package]]
name = "system-deps"
version = "6.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94af52f9402f94aac4948a2518b43359be8d9ce6cd9efc1c4de3b2f7b7e897d6"
dependencies = [
"cfg-expr",
"heck 0.4.1",
"pkg-config",
"toml 0.8.19",
"version-compare",
]
[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "target-lexicon"
version = "0.12.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1c7f239eb94671427157bd93b3694320f3668d4e1eff08c7285366fd777fac"
[[package]]
name = "tempfile"
version = "3.14.0"
@ -5037,6 +5412,17 @@ dependencies = [
"once_cell",
]
[[package]]
name = "tiff"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e"
dependencies = [
"flate2",
"jpeg-decoder",
"weezl",
]
[[package]]
name = "time"
version = "0.3.37"
@ -5278,7 +5664,7 @@ checksum = "2d080757c5d7404813f936147e3d72f7c035eba541c1422de29acd2242b98f36"
dependencies = [
"derive_more",
"hex",
"itertools",
"itertools 0.13.0",
"libc",
"paste",
"rand",
@ -5407,7 +5793,7 @@ dependencies = [
"educe",
"futures",
"humantime-serde",
"itertools",
"itertools 0.13.0",
"once_cell",
"oneshot-fused-workaround",
"pin-project",
@ -5451,7 +5837,7 @@ dependencies = [
"figment",
"fs-mistrust",
"futures",
"itertools",
"itertools 0.13.0",
"notify",
"once_cell",
"paste",
@ -5497,7 +5883,7 @@ dependencies = [
"http",
"httparse",
"httpdate",
"itertools",
"itertools 0.13.0",
"memchr",
"thiserror 1.0.69",
"tor-circmgr",
@ -5529,7 +5915,7 @@ dependencies = [
"hex",
"humantime",
"humantime-serde",
"itertools",
"itertools 0.13.0",
"memmap2",
"once_cell",
"oneshot-fused-workaround",
@ -5596,7 +5982,7 @@ dependencies = [
"futures",
"humantime",
"humantime-serde",
"itertools",
"itertools 0.13.0",
"num_enum",
"oneshot-fused-workaround",
"pin-project",
@ -5631,7 +6017,7 @@ dependencies = [
"data-encoding",
"derive_more",
"digest",
"itertools",
"itertools 0.13.0",
"paste",
"rand",
"safelog",
@ -5681,7 +6067,7 @@ dependencies = [
"glob-match",
"humantime",
"inventory",
"itertools",
"itertools 0.13.0",
"rand",
"serde",
"ssh-key",
@ -5711,7 +6097,7 @@ dependencies = [
"derive_builder_fork_arti",
"derive_more",
"hex",
"itertools",
"itertools 0.13.0",
"safelog",
"serde",
"serde_with",
@ -5807,7 +6193,7 @@ dependencies = [
"derive_more",
"futures",
"humantime",
"itertools",
"itertools 0.13.0",
"num_enum",
"rand",
"serde",
@ -5841,7 +6227,7 @@ dependencies = [
"educe",
"hex",
"humantime",
"itertools",
"itertools 0.13.0",
"once_cell",
"phf",
"serde",
@ -5877,7 +6263,7 @@ dependencies = [
"fs-mistrust",
"fslock",
"futures",
"itertools",
"itertools 0.13.0",
"oneshot-fused-workaround",
"paste",
"sanitize-filename",
@ -6000,7 +6386,7 @@ dependencies = [
"educe",
"futures",
"humantime",
"itertools",
"itertools 0.13.0",
"oneshot-fused-workaround",
"pin-project",
"priority-queue",
@ -6290,7 +6676,7 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3644627a5af5fa321c95b9b235a72fd24cd29c648c2c379431e6628655627bf"
dependencies = [
"itertools",
"itertools 0.13.0",
"unicode-segmentation",
"unicode-width 0.1.14",
]
@ -6378,6 +6764,17 @@ dependencies = [
"bindgen",
]
[[package]]
name = "v_frame"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6f32aaa24bacd11e488aa9ba66369c7cd514885742c9fe08cfe85884db3e92b"
dependencies = [
"aligned-vec",
"num-traits",
"wasm-bindgen",
]
[[package]]
name = "valuable"
version = "0.1.0"
@ -6390,6 +6787,12 @@ version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version-compare"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29"
[[package]]
name = "version_check"
version = "0.9.5"
@ -6532,6 +6935,12 @@ dependencies = [
"rustls-pki-types",
]
[[package]]
name = "weezl"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
[[package]]
name = "which"
version = "4.4.2"
@ -7129,6 +7538,7 @@ dependencies = [
"futures-util",
"gumdrop",
"hex",
"image",
"iso_currency",
"jubjub",
"minicbor",
@ -7260,3 +7670,27 @@ dependencies = [
"cc",
"pkg-config",
]
[[package]]
name = "zune-core"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a"
[[package]]
name = "zune-inflate"
version = "0.2.54"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02"
dependencies = [
"simd-adler32",
]
[[package]]
name = "zune-jpeg"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16099418600b4d8f028622f73ff6e3deaabdff330fb9a2a131dea781ee8b0768"
dependencies = [
"zune-core",
]

View File

@ -50,6 +50,7 @@ iso_currency = { version = "0.5", features = ["with-serde"] }
rust_decimal = "1"
# PCZT QR codes
image = { version = "0.25", optional = true }
minicbor = { version = "0.19", optional = true }
nokhwa = { version = "0.10", optional = true, features = ["input-native"] }
qrcode = { version = "0.14", optional = true, default-features = false }
@ -65,7 +66,7 @@ tui-logger = { version = "0.14", optional = true, features = ["tracing-support"]
[features]
default = ["transparent-inputs"]
pczt-qr = ["dep:minicbor", "dep:nokhwa", "dep:qrcode", "dep:rqrr", "dep:ur"]
pczt-qr = ["dep:image", "dep:minicbor", "dep:nokhwa", "dep:qrcode", "dep:rqrr", "dep:ur"]
transparent-inputs = [
"zcash_client_sqlite/transparent-inputs",
]

View File

@ -2,10 +2,12 @@ use std::time::Duration;
use anyhow::anyhow;
use gumdrop::Options;
use image::buffer::ConvertBuffer;
use minicbor::data::{Int, Type};
use nokhwa::{
pixel_format::LumaFormat,
utils::{CameraIndex, RequestedFormat, RequestedFormatType},
nokhwa_check, nokhwa_initialize,
pixel_format::RgbFormat,
utils::{RequestedFormat, RequestedFormatType, Resolution},
Camera,
};
use pczt::Pczt;
@ -85,10 +87,37 @@ pub(crate) struct Receive {
impl Receive {
pub(crate) async fn run(self, mut shutdown: ShutdownListener) -> Result<(), anyhow::Error> {
nokhwa_initialize(|_| ());
if !nokhwa_check() {
return Err(anyhow!("Failed to obtain macOS camera permissions"));
}
let cameras = nokhwa::query(nokhwa::utils::ApiBackend::Auto)?;
let camera = if cameras.len() > 1 {
eprintln!("Available cameras:");
for (i, camera) in cameras.iter().enumerate() {
eprintln!("{}: {}", i, camera.human_name());
}
eprint!("Select a camera: ");
cameras
.get(usize::from(stdin().read_u8().await?) - 48)
.ok_or(anyhow!("Invalid camera"))
} else {
cameras.first().ok_or(anyhow!("No camera"))
}?;
eprintln!("Creating camera");
let mut camera = Camera::new(
CameraIndex::Index(0),
RequestedFormat::new::<LumaFormat>(RequestedFormatType::AbsoluteHighestFrameRate),
camera.index().clone(),
RequestedFormat::new::<RgbFormat>(RequestedFormatType::AbsoluteHighestResolution),
)?;
eprintln!("Opening camera stream");
camera
.open_stream()
.map_err(|e| anyhow!("Could not open camera stream: {e}"))?;
eprintln!("Starting detection loop");
let mut decoder = ur::Decoder::default();
let mut interval = tokio::time::interval(Duration::from_millis(self.interval));
@ -96,11 +125,14 @@ impl Receive {
interval.tick().await;
if shutdown.requested() {
camera.stop_stream()?;
return Ok(());
}
let frame = camera.frame()?;
let decoded = frame.decode_image::<LumaFormat>()?;
// Doesn't work in nokhwa 0.10: https://github.com/l1npengtul/nokhwa/issues/100
// let decoded = frame.decode_image::<RgbFormat>()?;
let decoded = convert_buffer_to_image(frame)?;
let mut detect_grids = |mut img: rqrr::PreparedImage<
image::ImageBuffer<image::Luma<u8>, Vec<u8>>,
@ -122,11 +154,13 @@ impl Receive {
Ok(())
};
if let Err(e) = detect_grids(rqrr::PreparedImage::prepare(decoded)) {
if let Err(e) = detect_grids(rqrr::PreparedImage::prepare(decoded.convert())) {
eprintln!("Error while detecting grids: {e}");
}
}
camera.stop_stream()?;
let pczt_packet = decoder
.message()
.map_err(|e| anyhow!("Failed to extract full message from QR codes: {:?}", e))?
@ -212,3 +246,43 @@ where
}
Ok(())
}
fn convert_buffer_to_image(
buffer: nokhwa::Buffer,
) -> anyhow::Result<image::ImageBuffer<image::Rgb<u8>, Vec<u8>>> {
let Resolution {
width_x: width,
height_y: height,
} = buffer.resolution();
let mut image_buffer = image::ImageBuffer::<image::Rgb<u8>, Vec<u8>>::new(width, height);
let data = buffer.buffer();
for (y, chunk) in data
.chunks_exact((width * 2) as usize)
.enumerate()
.take(height as usize)
{
for (x, pixel) in chunk.chunks_exact(4).enumerate() {
let [u, y1, v, y2] = [
pixel[0] as f32,
pixel[1] as f32,
pixel[2] as f32,
pixel[3] as f32,
];
let x = (x * 2) as u32;
image_buffer.put_pixel(x, y as u32, yuv_to_rgb(y1, u, v));
image_buffer.put_pixel(x + 1, y as u32, yuv_to_rgb(y2, u, v));
}
}
Ok(image_buffer)
}
//YUV to RGB conversion BT.709
fn yuv_to_rgb(y: f32, u: f32, v: f32) -> image::Rgb<u8> {
let r = y + 1.5748 * (v - 128.0);
let g = y - 0.1873 * (u - 128.0) - 0.4681 * (v - 128.0);
let b = y + 1.8556 * (u - 128.0);
image::Rgb([r as u8, g as u8, b as u8])
}