yshui / index_camera_passthrough

Experimental Valve Index camera passthrough for Linux
MIT License
47 stars 2 forks source link

Crash with OG Vive camera #13

Open LeaPhant opened 8 months ago

LeaPhant commented 8 months ago

Using the OG Vive (single camera) by manually setting the camera path in config causes a crash in either VR backend.

[2024-03-05T15:55:16Z INFO  index_camera_passthrough] width          : 612
    height         : 460
    fourcc         : YUYV
    field          : progressive
    stride         : 1224
    size           : 563040
    colorspace     : sRGB
    quantization   : default
    transfer       : Rec. 709 transfer function
...
[2024-03-05T15:55:16Z WARN  index_camera_passthrough] No camera parameters found
[2024-03-05T15:55:16Z INFO  index_camera_passthrough::pipeline] Adjusted FOV: [[1.19, 1.19], [1.19, 1.19]]
Error: copy_buffer_to_image_info: `regions[0].buffer_offset` plus the number of bytes being copied is greater than `src_buffer.size()` (Vulkan VUIDs: VUID-VkCopyBufferToImageInfo2-pRegions-00171)

Backtrace (backtrace.log):

...
[2024-03-05T15:25:41Z TRACE index_camera_passthrough] state: Capturing
[2024-03-05T15:25:41Z TRACE index_camera_passthrough] getting camera frame
[2024-03-05T15:25:41Z TRACE index_camera_passthrough] got camera frame Instant { tv_sec: 7818, tv_nsec: 405975511 }
[2024-03-05T15:25:41Z TRACE index_camera_passthrough] state: Capturing
[2024-03-05T15:25:41Z TRACE index_camera_passthrough] getting camera frame
Error: copy_buffer_to_image_info: `regions[0].buffer_offset` plus the number of bytes being copied is greater than `src_buffer.size()`

Stack backtrace:
   0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
             at /home/lea/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.75/src/error.rs:551:25
   1: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
             at /rustc/d18480b84fdbf1efc34f62070951334aa833d761/library/core/src/result.rs:1964:27
   2: index_camera_passthrough::pipeline::Pipeline::submit_cpu_image
             at ./src/pipeline.rs:188:9
   3: index_camera_passthrough::pipeline::Pipeline::run
             at ./src/pipeline.rs:323:26
   4: index_camera_passthrough::main
             at ./src/main.rs:415:38
[2024-03-05T15:25:41Z TRACE index_camera_passthrough] got camera frame Instant { tv_sec: 7818, tv_nsec: 422727511 }
[2024-03-05T15:25:41Z TRACE index_camera_passthrough] state: Capturing
[2024-03-05T15:25:41Z TRACE index_camera_passthrough] getting camera frame

Changed config values:

backend = "OpenXR"
camera_device = "/dev/video0"
yshui commented 8 months ago

Right... the camera image size is hardcoded, so it doesn't work with vive camera.

Do you know what the resolution of the vive camera is?

LeaPhant commented 8 months ago

Do you know what the resolution of the vive camera is?

Technically 640x480, but with YUYV 4:2:2 it's 612x460 as in the logs.

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

        [0]: 'YUYV' (YUYV 4:2:2)
                Size: Discrete 612x460
                        Interval: Discrete 0.033s (30.000 fps)
                Size: Discrete 480x360
                        Interval: Discrete 0.033s (30.000 fps)
        [1]: 'MJPG' (Motion-JPEG, compressed)
                Size: Discrete 480x360
                        Interval: Discrete 0.008s (120.000 fps)
        [2]: 'H264' (H.264, compressed)
                Size: Discrete 480x360
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                Size: Discrete 612x460
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                Size: Discrete 320x240
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                Size: Discrete 160x120
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
                Size: Discrete 1920x1080
                        Interval: Discrete 0.033s (30.000 fps)
                        Interval: Discrete 0.042s (24.000 fps)
                        Interval: Discrete 0.050s (20.000 fps)
        [3]: 'NV12' (Y/UV 4:2:0)
                Size: Discrete 640x480
                        Interval: Discrete 0.020s (50.000 fps)
                Size: Discrete 480x360
                        Interval: Discrete 0.010s (100.000 fps)
yshui commented 8 months ago

does it have both eyes' image side-by-side? 612x460 seems to be really small.

LeaPhant commented 8 months ago

No, it's a single camera with a single non-square video output and yes, the quality is not great.

LeaPhant commented 8 months ago

For reference this is what a frame looks like:

mpv-shot0964

yshui commented 8 months ago

oh it's not stereo. OK, that's good.