l1npengtul / nokhwa

Cross Platform Rust Library for Powerful Webcam/Camera Capture
Apache License 2.0
502 stars 121 forks source link

Wrong colors in areas with high or low light #82

Open leofidus opened 1 year ago

leofidus commented 1 year ago

OS: Windows 11 22H2 Camera: Name: AI Front Camera, Description: MediaFoundation Camera, Extra: \\?\display#qcom_avstream_8280_lenv#3&98d97ee&1&uid32768#{e5323777-f976-4f5b-9b55-b94699c46e44}\{4faeafd4-041b-4e46-85fd-400473891182}, Index: 0 (webcam of a Lenovo X13s) Backend: input-native

I've been trying out the capture example, which I would assume to produce correct images out of the box. However, with my webcam I get correct colors in medium-light areas, but wrong colors in high or low light areas.

See the below two images, the first taken with cargo run -- single 0 img_test.png AbsoluteHighestResolution, the second with Window's Camera app.

img_test WIN_20221222_16_24_12_Pro

This looks like an HDR issue of some kind, but I'm not sure how to go about solving it.

l1npengtul commented 1 year ago

Unfortunately, I do not have access to any HDR webcam(s).

benpoulson commented 1 year ago

I don't believe it's related to HDR.

Here's a photo taken from a PS3 PlayStation Eye Webcam. 640×480 pixels - YUYV

img(1)

And then again via the OS app

image

Name: gspca main driver, Description: Video4Linux Device @ /dev/video3, Extra: , Index: 3
[dependencies]
image = "0.24.5"
nokhwa = { version = "0.10.3", features = ["input-native"] }

> uname -a
Linux Z790 5.19.0-29-generic #30-Ubuntu SMP PREEMPT_DYNAMIC Wed Jan 4 12:14:09 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.10
Release:        22.10
Codename:       kinetic
benpoulson commented 1 year ago

img

Fixed it, it was bad conversion in the yuyv444_to_rgb function. I know you're doing major refactoring currently, but would you like a PR for that change?

l1npengtul commented 1 year ago

@benpoulson That would be great, thank you! Sorry for the lack of progress, I'm dealing with some IRL issues at the moment 😅

yamt commented 10 months ago

my fix for a similar symptom: https://github.com/l1npengtul/nokhwa/pull/150