camera is almost there... waiting on upstream support from webcam libs lol

This commit is contained in:
Alex Janka 2023-03-19 15:44:45 +11:00
parent 47e2210b88
commit 7bd343ddec
6 changed files with 173 additions and 324 deletions

423
Cargo.lock generated
View file

@ -68,15 +68,6 @@ dependencies = [
"libc",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "anyhow"
version = "1.0.69"
@ -151,7 +142,7 @@ checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca"
dependencies = [
"addr2line",
"cc",
"cfg-if 1.0.0",
"cfg-if",
"libc",
"miniz_oxide",
"object",
@ -168,8 +159,8 @@ checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
name = "baseview"
version = "0.1.0"
dependencies = [
"cocoa 0.24.1",
"core-foundation 0.9.3",
"cocoa",
"core-foundation",
"keyboard-types",
"nix 0.22.3",
"objc",
@ -181,29 +172,6 @@ dependencies = [
"xcb-util",
]
[[package]]
name = "bindgen"
version = "0.56.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2da379dbebc0b76ef63ca68d8fc6e71c0f13e59432e0987e508c1820e6ab5239"
dependencies = [
"bitflags",
"cexpr 0.4.0",
"clang-sys",
"clap 2.34.0",
"env_logger",
"lazy_static",
"lazycell",
"log",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex 0.1.1",
"which",
]
[[package]]
name = "bindgen"
version = "0.61.0"
@ -211,7 +179,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a022e58a142a46fea340d68012b9201c094e93ec3d033a944a24f8fd4a4f09a"
dependencies = [
"bitflags",
"cexpr 0.6.0",
"cexpr",
"clang-sys",
"lazy_static",
"lazycell",
@ -220,7 +188,7 @@ dependencies = [
"quote",
"regex",
"rustc-hash",
"shlex 1.1.0",
"shlex",
"syn",
]
@ -296,30 +264,15 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
[[package]]
name = "cexpr"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27"
dependencies = [
"nom 5.1.2",
]
[[package]]
name = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
dependencies = [
"nom 7.1.3",
"nom",
]
[[package]]
name = "cfg-if"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -345,6 +298,16 @@ dependencies = [
"winapi",
]
[[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.6.0"
@ -356,21 +319,6 @@ dependencies = [
"libloading",
]
[[package]]
name = "clap"
version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim 0.8.0",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "clap"
version = "4.1.8"
@ -382,7 +330,7 @@ dependencies = [
"clap_lex",
"is-terminal",
"once_cell",
"strsim 0.10.0",
"strsim",
"termcolor",
"terminal_size",
]
@ -424,21 +372,6 @@ dependencies = [
"cc",
]
[[package]]
name = "cocoa"
version = "0.20.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c49e86fc36d5704151f5996b7b3795385f50ce09e3be0f47a0cfde869681cf8"
dependencies = [
"bitflags",
"block",
"core-foundation 0.7.0",
"core-graphics 0.19.2",
"foreign-types",
"libc",
"objc",
]
[[package]]
name = "cocoa"
version = "0.24.1"
@ -448,8 +381,8 @@ dependencies = [
"bitflags",
"block",
"cocoa-foundation",
"core-foundation 0.9.3",
"core-graphics 0.22.3",
"core-foundation",
"core-graphics",
"foreign-types",
"libc",
"objc",
@ -463,7 +396,7 @@ checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318"
dependencies = [
"bitflags",
"block",
"core-foundation 0.9.3",
"core-foundation",
"core-graphics-types",
"foreign-types",
"libc",
@ -496,16 +429,6 @@ dependencies = [
"memchr",
]
[[package]]
name = "core-foundation"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
dependencies = [
"core-foundation-sys 0.7.0",
"libc",
]
[[package]]
name = "core-foundation"
version = "0.9.3"
@ -522,30 +445,12 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7ca8a5221364ef15ce201e8ed2f609fc312682a8f4e0e3d4aa5879764e0fa3b"
[[package]]
name = "core-foundation-sys"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
[[package]]
name = "core-foundation-sys"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "core-graphics"
version = "0.19.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923"
dependencies = [
"bitflags",
"core-foundation 0.7.0",
"foreign-types",
"libc",
]
[[package]]
name = "core-graphics"
version = "0.22.3"
@ -553,7 +458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2581bbab3b8ffc6fcbd550bf46c355135d16e9ff2a6ea032ad6b9bf1d7efe4fb"
dependencies = [
"bitflags",
"core-foundation 0.9.3",
"core-foundation",
"core-graphics-types",
"foreign-types",
"libc",
@ -566,36 +471,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b"
dependencies = [
"bitflags",
"core-foundation 0.9.3",
"core-foundation",
"foreign-types",
"libc",
]
[[package]]
name = "core-media-sys"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "273bf3fc5bf51fd06a7766a84788c1540b6527130a0bce39e00567d6ab9f31f1"
dependencies = [
"cfg-if 0.1.10",
"core-foundation-sys 0.7.0",
"libc",
]
[[package]]
name = "core-video-sys"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828"
dependencies = [
"cfg-if 0.1.10",
"core-foundation-sys 0.7.0",
"core-graphics 0.19.2",
"libc",
"metal 0.18.0",
"objc",
]
[[package]]
name = "coreaudio-rs"
version = "0.11.2"
@ -613,7 +493,7 @@ version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a9444b94b8024feecc29e01a9706c69c1e26bfee480221c90764200cfd778fb"
dependencies = [
"bindgen 0.61.0",
"bindgen",
]
[[package]]
@ -622,7 +502,7 @@ version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a7847ca018a67204508b77cb9e6de670125075f7464fff5f673023378fa34f5"
dependencies = [
"core-foundation 0.9.3",
"core-foundation",
"core-foundation-sys 0.8.3",
"coremidi-sys",
]
@ -667,7 +547,7 @@ version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-epoch",
@ -681,7 +561,7 @@ version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf2b3e8478797446514c91ef04bafcb59faba183e621ad488df88983cc14128c"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"crossbeam-utils",
]
@ -691,7 +571,7 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"crossbeam-epoch",
"crossbeam-utils",
]
@ -703,7 +583,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46bd5f3f85273295a9d14aedfb86f6aadbff6d8f5295c4a9edb08e819dcf5695"
dependencies = [
"autocfg",
"cfg-if 1.0.0",
"cfg-if",
"crossbeam-utils",
"memoffset 0.8.0",
"scopeguard",
@ -715,7 +595,7 @@ version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"crossbeam-utils",
]
@ -725,7 +605,7 @@ version = "0.8.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c063cd8cc95f5c377ed0d4b49a4b21f632396ff690e8470c29b3359b346984b"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
]
[[package]]
@ -819,7 +699,7 @@ dependencies = [
"ident_case",
"proc-macro2",
"quote",
"strsim 0.10.0",
"strsim",
"syn",
]
@ -867,19 +747,6 @@ version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]]
name = "env_logger"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]]
name = "errno"
version = "0.2.8"
@ -1046,7 +913,7 @@ dependencies = [
name = "gb-emu"
version = "0.1.0"
dependencies = [
"clap 4.1.8",
"clap",
"cpal",
"ctrlc",
"futures",
@ -1054,6 +921,7 @@ dependencies = [
"gilrs",
"minifb",
"nokhwa",
"send_wrapper",
]
[[package]]
@ -1075,7 +943,7 @@ version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"js-sys",
"libc",
"wasi",
@ -1101,7 +969,7 @@ version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6789d356476c3280a4e15365d23f62b4b4f1bcdac81fdd552f65807bce4666dd"
dependencies = [
"core-foundation 0.9.3",
"core-foundation",
"io-kit-sys",
"js-sys",
"libc",
@ -1231,12 +1099,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "iana-time-zone"
version = "0.1.53"
@ -1297,7 +1159,7 @@ version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"js-sys",
"wasm-bindgen",
"web-sys",
@ -1475,7 +1337,7 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"winapi",
]
@ -1520,7 +1382,7 @@ version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
]
[[package]]
@ -1550,6 +1412,12 @@ dependencies = [
"libc",
]
[[package]]
name = "maplit"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d"
[[package]]
name = "memchr"
version = "2.5.0"
@ -1574,21 +1442,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "metal"
version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e198a0ee42bdbe9ef2c09d0b9426f3b2b47d90d93a4a9b0395c4cea605e92dc0"
dependencies = [
"bitflags",
"block",
"cocoa 0.20.2",
"core-graphics 0.19.2",
"foreign-types",
"log",
"objc",
]
[[package]]
name = "metal"
version = "0.24.0"
@ -1777,10 +1630,10 @@ dependencies = [
"backtrace",
"baseview",
"bitflags",
"cfg-if 1.0.0",
"clap 4.1.8",
"cfg-if",
"clap",
"clap-sys",
"core-foundation 0.9.3",
"core-foundation",
"cpal",
"crossbeam",
"jack",
@ -1830,7 +1683,7 @@ checksum = "e4916f159ed8e5de0082076562152a76b7a1f64a01fd9d1e0fea002c37624faf"
dependencies = [
"bitflags",
"cc",
"cfg-if 1.0.0",
"cfg-if",
"libc",
"memoffset 0.6.5",
]
@ -1842,7 +1695,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
"cfg-if",
"libc",
"memoffset 0.6.5",
]
@ -1855,7 +1708,7 @@ checksum = "f346ff70e7dbfd675fe90590b92d59ef2de15a8779ae305ebcbfd3f0caf59be4"
dependencies = [
"autocfg",
"bitflags",
"cfg-if 1.0.0",
"cfg-if",
"libc",
]
@ -1866,7 +1719,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a"
dependencies = [
"bitflags",
"cfg-if 1.0.0",
"cfg-if",
"libc",
"static_assertions",
]
@ -1879,52 +1732,13 @@ checksum = "143c7e68ab35542605825430efb8acaf977de40d4256ebfeed6324b35a6ba89a"
dependencies = [
"flume",
"image",
"nokhwa-bindings-linux",
"nokhwa-bindings-macos",
"nokhwa-bindings-windows",
"nokhwa-core",
"opencv",
"paste",
"rgb",
"thiserror",
]
[[package]]
name = "nokhwa-bindings-linux"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "448db09af68e12168b6311423409f679d2da6e75fb158b2d75de2f5d6dc460ca"
dependencies = [
"nokhwa-core",
"v4l",
"v4l2-sys-mit",
]
[[package]]
name = "nokhwa-bindings-macos"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cb2044194c8cc0286a0bfae023caeb434c32900ffe3f3d08565362306437be8"
dependencies = [
"block",
"cocoa-foundation",
"core-media-sys",
"core-video-sys",
"flume",
"nokhwa-core",
"objc",
"once_cell",
]
[[package]]
name = "nokhwa-bindings-windows"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9b9bae36d0ce413568cefb94c43748e80f9ae97aa0a9e2d8e18f0275a909746"
dependencies = [
"nokhwa-core",
"once_cell",
"windows 0.43.0",
]
[[package]]
name = "nokhwa-core"
version = "0.1.0"
@ -1934,19 +1748,10 @@ dependencies = [
"bytes",
"image",
"mozjpeg",
"opencv",
"thiserror",
]
[[package]]
name = "nom"
version = "5.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af"
dependencies = [
"memchr",
"version_check",
]
[[package]]
name = "nom"
version = "7.1.3"
@ -2085,13 +1890,49 @@ version = "1.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3"
[[package]]
name = "opencv"
version = "0.74.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33bd2442759725e3ce38862b32acb1999de51e9f3f4310f3b01b7f0623091d74"
dependencies = [
"cc",
"clang",
"dunce",
"jobserver",
"libc",
"num-traits",
"once_cell",
"opencv-binding-generator",
"pkg-config",
"rgb",
"semver",
"shlex",
"vcpkg",
]
[[package]]
name = "opencv-binding-generator"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "082d8259f4a7ea455e3553f9a1bc817520eb465a153bbf5ec0cb0b73590ee28d"
dependencies = [
"clang",
"clang-sys",
"dunce",
"maplit",
"once_cell",
"percent-encoding",
"regex",
]
[[package]]
name = "orbclient"
version = "0.3.43"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "974465c5e83cf9df05c1e4137b271d29035c902e39e5ad4c1939837e22160af8"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"libc",
"raw-window-handle 0.3.4",
"redox_syscall",
@ -2123,7 +1964,7 @@ version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
@ -2142,6 +1983,12 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "percent-encoding"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e"
[[package]]
name = "pin-project"
version = "1.0.12"
@ -2506,12 +2353,24 @@ version = "0.35.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3586be2cf6c0a8099a79a12b4084357aa9b3e0b0d7980e3b67aaf7a9d55f9f0"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"cmake",
"libc",
"version-compare",
]
[[package]]
name = "semver"
version = "1.0.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bebd363326d05ec3e2f532ab7660680f3b02130d780c299bca73469d521bc0ed"
[[package]]
name = "send_wrapper"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73"
[[package]]
name = "serde"
version = "1.0.156"
@ -2580,12 +2439,6 @@ dependencies = [
"syn",
]
[[package]]
name = "shlex"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
[[package]]
name = "shlex"
version = "1.1.0"
@ -2641,12 +2494,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "strsim"
version = "0.10.0"
@ -2670,7 +2517,7 @@ version = "3.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af18f7ae1acd354b992402e9ec5864359d693cd8a79dcbef59f76891701c1e95"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"fastrand",
"redox_syscall",
"rustix",
@ -2696,15 +2543,6 @@ dependencies = [
"windows-sys 0.45.0",
]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]]
name = "thiserror"
version = "1.0.39"
@ -2837,24 +2675,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1674845326ee10d37ca60470760d4288a6f80f304007d92e5c53bab78c9cfd79"
[[package]]
name = "v4l"
version = "0.13.1"
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd9946a2fda19c7a729dc72e28b9fd9c653e9b7de954ffe3aecaf51977f88762"
dependencies = [
"bitflags",
"libc",
"v4l2-sys-mit",
]
[[package]]
name = "v4l2-sys-mit"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0c932c06df4af1dfb229f604214f2a87993784596ff33ffdadcba1b5519254e"
dependencies = [
"bindgen 0.56.0",
]
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "vec_map"
@ -2947,7 +2771,7 @@ version = "0.2.84"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"wasm-bindgen-macro",
]
@ -2972,7 +2796,7 @@ version = "0.4.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454"
dependencies = [
"cfg-if 1.0.0",
"cfg-if",
"js-sys",
"wasm-bindgen",
"web-sys",
@ -3159,7 +2983,7 @@ dependencies = [
"khronos-egl",
"libloading",
"log",
"metal 0.24.0",
"metal",
"naga",
"objc",
"parking_lot",
@ -3184,15 +3008,6 @@ dependencies = [
"bitflags",
]
[[package]]
name = "which"
version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
dependencies = [
"libc",
]
[[package]]
name = "wide"
version = "0.7.8"
@ -3402,7 +3217,7 @@ version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "463705a63313cd4301184381c5e8042f0a7e9b4bb63653f216311d4ae74690b7"
dependencies = [
"nom 7.1.3",
"nom",
]
[[package]]

View file

@ -3,6 +3,10 @@ name = "gb-emu"
version = "0.1.0"
edition = "2021"
[features]
default = []
camera = ["dep:nokhwa", "dep:send_wrapper"]
[dependencies]
gb-emu-lib = { path = "../lib" }
clap = { version = "4.1.8", features = ["derive"] }
@ -11,4 +15,5 @@ gilrs = "0.10"
cpal = "0.15"
futures = "0.3"
ctrlc = "3.2.5"
nokhwa = { version = "0.10.3", features = ["input-native"] }
nokhwa = { version = "0.10.3", features = ["input-opencv"], optional = true }
send_wrapper = { version = "0.6.0", optional = true }

View file

@ -4,40 +4,51 @@ use nokhwa::{
utils::{CameraIndex, RequestedFormat, RequestedFormatType},
Camera,
};
use send_wrapper::SendWrapper;
pub struct Webcam {
camera: Camera,
camera: SendWrapper<Camera>,
buffer: [u8; 128 * 128],
}
impl Webcam {
pub fn new() -> Self {
let format = RequestedFormat::new::<pixel_format::LumaFormat>(
let format = RequestedFormat::new::<pixel_format::LumaAFormat>(
RequestedFormatType::AbsoluteHighestResolution,
);
println!("creating webcam");
Self {
camera: Camera::new(CameraIndex::Index(0), format).unwrap(),
camera: SendWrapper::new(Camera::new(CameraIndex::Index(0), format).unwrap()),
buffer: [0; 128 * 128],
}
}
}
impl PocketCamera for Webcam {
fn get_image(&mut self) -> [u8; 128 * 128] {
let frame = self
.camera
.frame()
.unwrap()
.decode_image::<pixel_format::LumaFormat>()
.unwrap();
let mut buffer = [0; 128 * 128];
for y in 0..128 {
for x in 0..128 {
buffer[y * 128 + x] = frame[(x as u32, y as u32)].0[0];
}
}
buffer
println!("getting image");
self.buffer
}
fn begin_capture(&mut self) {
todo!()
let height = self.camera.resolution().height() as usize;
let width = self.camera.resolution().width() as usize;
let frame = self.camera.frame_raw().expect("couldn't get frame");
println!(
"buffer length: {}, resolution length: {}",
frame.len(),
width * height
);
for y in 0..128 {
for x in 0..128 {
self.buffer[y * 128 + x] = frame[((y * width) + x) * 2];
}
}
println!("captured");
}
fn init(&mut self) {
self.camera.open_stream().expect("couldn't open stream");
}
}

View file

@ -1,9 +1,11 @@
#![feature(let_chains)]
#[cfg(feature = "camera")]
use camera::Webcam;
use clap::{ArgGroup, Parser};
use gb_emu_lib::{
connect::{EmulatorMessage, EmulatorOptions, RomFile, SerialTarget},
connect::{EmulatorMessage, EmulatorOptions, NoCamera, RomFile, SerialTarget},
EmulatorCore,
};
use gilrs::Gilrs;
@ -12,6 +14,7 @@ use std::sync::mpsc::channel;
use window::WindowRenderer;
mod audio;
#[cfg(feature = "camera")]
mod camera;
mod window;
@ -83,10 +86,16 @@ fn main() {
let (output, _stream) = audio::create_output();
let options = EmulatorOptions::new(
#[cfg(feature = "webcam")]
let camera = Webcam::new();
#[cfg(not(feature = "webcam"))]
let camera = NoCamera::default();
let options = EmulatorOptions::new_with_camera(
WindowRenderer::new(factor, Some(Gilrs::new().unwrap())),
RomFile::Path(args.rom),
output,
camera,
)
.with_save_path(args.save)
.with_serial_target(if args.connect_serial {
@ -99,8 +108,12 @@ fn main() {
.with_verbose(args.verbose)
.with_tile_window(tile_window);
println!("made options");
let mut core = EmulatorCore::init(receiver, options);
println!("made core");
match args.step_by {
Some(step_size) => loop {
core.run_stepped(step_size);

View file

@ -71,6 +71,8 @@ pub trait PocketCamera {
fn get_image(&mut self) -> [u8; 128 * 128];
fn begin_capture(&mut self);
fn init(&mut self);
}
pub struct NoCamera {
@ -95,6 +97,8 @@ impl PocketCamera for NoCamera {
*v = rand::random();
}
}
fn init(&mut self) {}
}
pub(crate) type CameraWrapperRef<C> = Arc<Mutex<CameraWrapper<C>>>;

View file

@ -45,6 +45,7 @@ where
camera: CameraWrapperRef<C>,
) -> Self {
let ram = ram_size_kb(ram_size).map(|s| MaybeBufferedSram::new(save_file, s * KB));
camera.lock().unwrap().inner.init();
Self {
data,
rom_bank: 1,