简体   繁体   English

V4L2:控制设置+软件触发

[英]V4L2 : control setting + software trigger

I am working on jetson TX2, with a FSM-IMX304M camera and I use V4L2 API.我正在使用 FSM-IMX304M 相机开发 jetson TX2,我使用 V4L2 API。

I would like to use software trigger.我想使用软件触发。 Does anyone have an idea about how to use it?有谁知道如何使用它? I didn't find anything about it.我没有找到任何关于它的东西。

I need to synchronize the camera with a turntable.我需要将相机与转盘同步。 The idea is to send x triggers every 50 ms (read-out time of the camera is around 50ms), to fill x buffers (the minimum buffer id is 3 and the maximal is 32).这个想法是每 50 毫秒发送 x 个触发器(相机的读出时间约为 50 毫秒),以填充 x 个缓冲区(最小缓冲区 id 为 3,最大为 32)。 When the first buffer is filled, I send an other trigger to fill the second one, and during this time, the camera send the image to the jetson.当第一个缓冲区被填满时,我发送另一个触发器来填充第二个缓冲区,在此期间,相机将图像发送到 jetson。

I try to implement this solution because it is consuming time to stop/start stream for each sequence ( https://www.kernel.org/doc/html/v4.10/media/uapi/v4l/vidioc-streamon.html ). I try to implement this solution because it is consuming time to stop/start stream for each sequence ( https://www.kernel.org/doc/html/v4.10/media/uapi/v4l/vidioc-streamon.html ) . If this solution is not feasible, does someone have an other idea?如果此解决方案不可行,是否有人有其他想法?

Moreover, I try to change the exposure time of my camera.此外,我尝试改变相机的曝光时间。 I just this tutorial: https://www.kernel.org/doc/html/v4.10/media/uapi/v4l/control.html#example-enumerating-all-controls-including-compound-controls .我只是这个教程: https://www.kernel.org/doc/html/v4.10/media/uapi/v4l/control.html#example-enumerating-all-controls-including-compound-controls To change the exposure time:要更改曝光时间:

struct v4l2_queryctrl queryctrl;
struct v4l2_control control;

memset(&queryctrl, 0, sizeof(queryctrl));
queryctrl.id = V4L2_CID_EXPOSURE;

if (-1 == ioctl(fd, VIDIOC_QUERYCTRL, &queryctrl)) {
    if (errno != EINVAL) {
        perror("VIDIOC_QUERYCTRL");
        exit(EXIT_FAILURE);
    } else {
        printf("V4L2_CID_EXPOSURE is not supported 1 \n");
    }
} else if (queryctrl.flags & V4L2_CTRL_FLAG_DISABLED) {
    printf("V4L2_CID_EXPOSURE is not supported 1 \n");
} else {
    memset(&control, 0, sizeof (control));
    control.id = V4L2_CID_EXPOSURE;
    control.value = queryctrl.default_value;

    if (-1 == ioctl(fd, VIDIOC_S_CTRL, &control)) {
        perror("VIDIOC_S_CTRL");
        exit(EXIT_FAILURE);
    }
}

The code returns: V4L2_CID_EXPOSURE is not supported 1 .代码返回: V4L2_CID_EXPOSURE is not supported 1

Maybe this command from linux command line can help you to figure out the issue:也许 linux 命令行中的这个命令可以帮助您找出问题所在:

nvidia@nvidia-desktop:~$ v4l2-compliance -d /dev/video0
v4l2-compliance SHA   : not available

Driver Info:
    Driver name   : tegra-video
    Card type     : vi-output, imx304 30-001a
    Bus info      : platform:15700000.vi:0
    Driver version: 4.9.140
    Capabilities  : 0x84200001
        Video Capture
        Streaming
        Extended Pix Format
        Device Capabilities
    Device Caps   : 0x04200001
        Video Capture
        Streaming
        Extended Pix Format

Compliance test for device /dev/video0 (not using libv4l2):

Required ioctls:
    test VIDIOC_QUERYCAP: OK

Allow for multiple opens:
    test second video open: OK
    test VIDIOC_QUERYCAP: OK
    test VIDIOC_G/S_PRIORITY: OK
    test for unlimited opens: OK

Debug ioctls:
    test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
    test VIDIOC_LOG_STATUS: OK

Input ioctls:
    test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
    test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
    test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
    test VIDIOC_ENUMAUDIO: OK (Not Supported)
    test VIDIOC_G/S/ENUMINPUT: OK
    test VIDIOC_G/S_AUDIO: OK (Not Supported)
    Inputs: 1 Audio Inputs: 0 Tuners: 0

Output ioctls:
    test VIDIOC_G/S_MODULATOR: OK (Not Supported)
    test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
    test VIDIOC_ENUMAUDOUT: OK (Not Supported)
    test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
    test VIDIOC_G/S_AUDOUT: OK (Not Supported)
    Outputs: 0 Audio Outputs: 0 Modulators: 0

Input/Output configuration ioctls:
    test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
    test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
    test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
    test VIDIOC_G/S_EDID: OK (Not Supported)

Test input 0:

    Control ioctls:
        test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
        test VIDIOC_QUERYCTRL: OK
        test VIDIOC_G/S_CTRL: OK
        test VIDIOC_G/S/TRY_EXT_CTRLS: OK
        test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
        test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
        Standard Controls: 1 Private Controls: 24

    Format ioctls:
        test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
        fail: v4l2-test-formats.cpp(1184): ret && node->has_frmintervals
        test VIDIOC_G/S_PARM: FAIL
        test VIDIOC_G_FBUF: OK (Not Supported)
        test VIDIOC_G_FMT: OK
        test VIDIOC_TRY_FMT: OK
        test VIDIOC_S_FMT: OK
        test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
        test Cropping: OK (Not Supported)
        test Composing: OK (Not Supported)
        test Scaling: OK (Not Supported)

    Codec ioctls:
        test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
        test VIDIOC_G_ENC_INDEX: OK (Not Supported)
        test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)

    Buffer ioctls:
        test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
        test VIDIOC_EXPBUF: OK

Test input 0:


Total: 43, Succeeded: 42, Failed: 1, Warnings: 0

Thank you for your help谢谢您的帮助

The nvidia developers have expanded the set of controls for v4l2 . nvidia 开发人员扩展了v4l2的控件集。

You need to look at the tegra-v4l2-camera.h file.您需要查看tegra-v4l2-camera.h文件。 For example for exposure, the definition will be TEGRA_CAMERA_CID_EXPOSURE .例如对于曝光,定义将是TEGRA_CAMERA_CID_EXPOSURE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM