DerFetzer / spectro-cam-rs

A cross-platform GUI for webcam-based spectrometers.
Apache License 2.0
10 stars 3 forks source link

Raw BGGR frame Bayer filter sampling feature? #1

Closed Joel-Mckay closed 1 month ago

Joel-Mckay commented 1 month ago

I saw someone is removing the Bayer filter in the "Little Garden Spectrometer" cameras, and was curious if anyone has already looked into the increased bit depth of the RAW BGGR green channel, and physical pixel location on the sensors (taking the staggered horizontal lines gaps and interleaving into a half vertical frame resolution to improve horizontal resolution display).

Was about to write something myself in opencv, but saw this project was well developed already. (mentioned in https://budgetlightforum.com/t/little-garden-spectrometer-impressions-opinions-discussion/225545 )

I guess this is a documentation and or feature request for Linux platforms with some USB cameras. Best regards =)

DerFetzer commented 1 month ago

This is very interesting! Thanks for sharing.

The question is if the camera can even output the raw sensor data (https://www.kernel.org/doc/html/v5.6/media/uapi/v4l/pixfmt-bayer.html).

The i-PhosHD cannot when I remember correctly. If you can point me to a model that does, I could have a look. As long as it can be bought somewhere to a reasonable prize, of course.

Joel-Mckay commented 1 month ago

I ordered 2 samples of Lao Kang's version of the "Theremino spectometer" from here: https://www.aliexpress.com/item/1005007241834839.html

I will be testing the v4l2 camera driver support for "RG12", "YUYV 4:2:2", or "UYVY" formats v4l2-ctl -d /dev/video0 --list-formats-ext v4l2-ctl --list-formats

My intent was to look into the bindings for raw frame access in a rust compatible cam wrapper library: https://github.com/l1npengtul/nokhwa

If the results are reasonable, eventually I want to add a 3D printed narrow-band optical filter-holder wheel stepper-controller for an Arduino sketch to the project (sending a simple serial command to index the wheel, read from a zero marker, and suppress the spurious diffraction spikes in the spectra etc.).

I will update the thread with the models PID:VID USB device details when it arrives in a few weeks.

Joel-Mckay commented 1 month ago

Ok, so I manged to pull the camera hardware model from the device: 0c68:6464 Sonix Technology Co., Ltd. USB 2.0 Camera

The driver does not provide raw frame access, but thanks for the tips. I will still fork the code to add some features in a few weeks. The 3D prints should be easy to modify as needed. =)

` v4l2-ctl -d /dev/video0 --list-formats-ext ioctl: VIDIOC_ENUM_FMT Type: Video Capture

[0]: 'MJPG' (Motion-JPEG, compressed)
    Size: Discrete 1920x1080
        Interval: Discrete 0.033s (30.000 fps)
        Interval: Discrete 0.067s (15.000 fps)
    Size: Discrete 352x288
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 432x240
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 320x184
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 176x144
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 160x120
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 320x240
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 640x360
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 640x480
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 800x600
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 960x720
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 1024x768
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 1280x720
        Interval: Discrete 0.032s (31.000 fps)
    Size: Discrete 1280x960
        Interval: Discrete 0.033s (30.000 fps)
[1]: 'YUYV' (YUYV 4:2:2)
    Size: Discrete 1920x1080
        Interval: Discrete 0.200s (5.000 fps)
    Size: Discrete 352x288
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 432x240
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 320x184
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 176x144
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 160x120
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 320x240
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 640x360
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 640x480
        Interval: Discrete 0.033s (30.000 fps)
    Size: Discrete 800x600
        Interval: Discrete 0.048s (21.000 fps)
    Size: Discrete 960x720
        Interval: Discrete 0.091s (11.000 fps)
    Size: Discrete 1024x768
        Interval: Discrete 0.077s (13.000 fps)
    Size: Discrete 1280x720
        Interval: Discrete 0.111s (9.000 fps)
    Size: Discrete 1280x960
        Interval: Discrete 0.167s (6.000 fps)

`