1

How can i detect camera device(s) using gnome libraries.

Please get me some sample codes regarding this.

I have followed Cheese source code, but when i call detect camera api, it returns NULL.

Thanks and Regards, iSight

Community
  • 1
  • 1
boom
  • 5,194
  • 21
  • 52
  • 88

1 Answers1

2

from my understanding, you don't really need to use gnome\gtk if what you need is webcam device information. Pls, try the code below, it should query and output video driver capabilities:

#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>

int main()
{
    struct v4l2_capability vc;
    int fd = open("/dev/video0", O_RDONLY);
    if (fd != -1)
    {
        ioctl(fd, VIDIOC_QUERYCAP, &vc);

        printf("driver: %s\n", vc.driver);
        printf("card: %s\n", vc.card);
        printf("bus info: %s\n", vc.bus_info);
        printf("version: %d\n", vc.version);
        printf("capabilities: %x\n", vc.capabilities);

        close(fd);
    }
    return 0;
}

on my machine output is:

driver: uvcvideo

card: Lenovo EasyCamera

bus info: usb-0000:00:1d.7-3

version: 256

capabilities: 4000001

you also can find more info here: How to get a list of video capture devices (web cameras) on linux

hope this helps, regards

Community
  • 1
  • 1
serge_gubenko
  • 18,998
  • 2
  • 57
  • 61