l1npengtul/nokhwa

[Request] BGR and GBR support

RivenSkaye opened this issue · 1 comments

Platform: Windows 10 (x86_64)
Toolchain: both msvc and gcc
rustc:

rustc 1.78.0-nightly (3cbb93223 2024-03-13)
binary: rustc
commit-hash: 3cbb93223f33024db464a4df27a13c7cce870173
commit-date: 2024-03-13
host: x86_64-pc-windows-msvc
release: 1.78.0-nightly
LLVM version: 18.1.0

Nokhwa version: 0.10.4 (latest on crates)

Currently Nokhwa only supports raw RGB, in that planar order too AFAICT. But some cameras only output in specific orders, as well as some video decoders (zimg, I think ffmpeg's raw format too?), and produce BGR or GBR for some reason. This is causing some... odd effects, to say the least.
Screenshare pushed out as dummy cam:

RawRGB on bgr format:
test-1

I'm also not sure if it's a known (or even related) issue with YUYV422, but uhhh:
test-04

And a clean frame from the same source:
AlterCam_Snapshot 2024-3-20 10-19-57-706

Pushing the data reversed for RGB provides the correct colors and vertical alignment, only horizontally it's still flipped. And that should just be a matter of strides
It entirely fixes it for BGR and I really shouldn't forget to cargo clean in between experimenting