Posts

Showing posts from October, 2018

Getting information about list of installed webcams programmatically using udev

If your writing an application in Linux where you dealing with low-level hardware details, using udev is a better choice rather than calling executable and reading the content in their STDOUT This is a small C code to get information about list of installed webcam programmatically using udev. This is written in C, this can be integrated with other languages such as Python, Java using a wrapper interface such as JNI(Java) or Python/C API   #include <libudev.h> #include <stdio.h> #include <stdlib.h> #include <locale.h> #include <unistd.h> int main(void) { struct udev * udev; struct udev_enumerate * enumerate; struct udev_list_entry * devices, * dev_list_entry; struct udev_device * dev; /* Create the udev object */ udev = udev_new(); if (!udev) { printf("Can't create udev\n"); exit(1); } /* Create a list of the devices in the 'video4linux' subsystem. */ enumerate = udev_enumerate_new(udev); udev_enu