Skip to content

Handle non discrete frame sizes

Sander G. van Dijk requested to merge handle-non-discrete-frame-sizes into foxy

V4L2 supports 3 ways of specifying valid frame sizes: as a discrete set of sizes, as a min and max size and a step size, or as a min and max size with all possible sizes in between (continuous). So far this package only handled discrete types, and would actually crash on others (which is what happened in #22 (closed)).

This adds handling of stepped and continuous sizes as well, most importantly right now to create parameter descriptions. The new representations would also be useful to warn or enforce image sizes as discussed in #20.

I have tested this on a Raspberry Pi 4b with a Camera Module V2, which uses stepped sizes. Inspecting the image_size parameter on it gives:

$ ros2 param describe /v4l2_camera image_size                                                         
Parameter name: image_size
  Type: integer array
  Description: Image width & height
  Constraints:
    Additional constraints: Available image sizes:
YU12 (Planar YUV 4:2:0)
        min:    32x32
        max:    3280x2464
        step:   2x2
YUYV (YUYV 4:2:2)
        min:    32x32
        max:    3280x2464
        step:   2x2
RGB3 (24-bit RGB 8-8-8)
        min:    32x32
        max:    3280x2464
        step:   2x2
JPEG (JFIF JPEG)
        min:    32x32
        max:    3280x2464
        step:   2x2
H264 (H.264)
        min:    32x32
        max:    3280x2464
        step:   2x2
MJPG (Motion-JPEG)
        min:    32x32
        max:    3280x2464
        step:   2x2
YVYU (YVYU 4:2:2)
        min:    32x32
        max:    3280x2464
        step:   2x2
VYUY (VYUY 4:2:2)
        min:    32x32
        max:    3280x2464
        step:   2x2
UYVY (UYVY 4:2:2)
        min:    32x32
        max:    3280x2464
        step:   2x2
NV12 (Y/CbCr 4:2:0)
        min:    32x32
        max:    3280x2464
        step:   2x2
BGR3 (24-bit BGR 8-8-8)
        min:    32x32
        max:    3280x2464
        step:   2x2
YV12 (Planar YVU 4:2:0)
        min:    32x32
        max:    3280x2464
        step:   2x2
NV21 (Y/CrCb 4:2:0)
        min:    32x32
        max:    3280x2464
        step:   2x2
BGR4 (32-bit BGRA/X 8-8-8-8)
        min:    32x32
        max:    3280x2464
        step:   2x2

So this closes #22 (closed).

Merge request reports