VIDIOC_QUERYCAP:设备的 ioctl 不合适

时间:2021-02-13 05:02:32

标签: ioctl v4l2

我正在尝试使用 v4l2 库编写自己的代码,但是当我尝试从相机获取功能时,我的代码总是出错。但是我拥有的其他代码做同样的事情根本不会崩溃。有谁知道为什么?

我的代码:

int fd;
if((fd = open("/dev/video0", O_RDWR)) < 0){
    perror("Couldn't open camera");
    return 1;
}

//getting the camera's capabilities
v4l2_capability cap;
if(ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0){
    perror("Can't get the camera's capabilites");
    return 1;
}

其他人的代码:

int fd; // A file descriptor to the video device
if((fd = open("/dev/video0",O_RDWR)) < 0){
    perror("Failed to open device, OPEN");
    return 1;
}


// 2. Ask the device if it can capture frames
v4l2_capability cap;
if(ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0){
    // something went wrong... exit
    perror("Failed to get device capabilities, VIDIOC_QUERYCAP");
    return 1;
}

这是错误: VIDIOC_QUERYCAP:设备的 ioctl 不合适

0 个答案:

没有答案