a simple c++ wrapper of v4l2
pthread opencv-core opencv-highgui
provide two ways to get image frame
-
query
V4l2Camera webcam("/dev/video0"); webcam.openCameraDevice(640, 480, V4L2_PIX_FMT_MJPEG); grabAndRender(webcam, 60*5, fmt); //60*5 seconds webcam.closeCameraDevice();
-
callback
V4l2Camera webcam("/dev/video0"); webcam.openCameraDevice(640, 480, V4L2_PIX_FMT_MJPEG); webcam.startStreaming(callback, &webcam); sleep(60*5); webcam.stopStreaming(); webcam.closeCameraDevice();