All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.sarxos.webcam.ds.v4l4j.V4l4jDriver Maven / Gradle / Ivy

Go to download

Webcam Capture driver using V4L2 Java binding (V4L4J project) to grab frames from camera devices

There is a newer version: 0.3.12
Show newest version
package com.github.sarxos.webcam.ds.v4l4j;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.github.sarxos.v4l4j.V4L4J;
import com.github.sarxos.webcam.WebcamDevice;
import com.github.sarxos.webcam.WebcamDriver;
import com.github.sarxos.webcam.util.NixVideoDevUtils;


/**
 * Capture driver for V4L4J framework. For more details on V4L4J please check http://code.google.com/p/v4l4j
 * 
 * @author Bartosz Firyn (sarxos)
 */
public class V4l4jDriver implements WebcamDriver {

	/**
	 * Logger.
	 */
	private static final Logger LOG = LoggerFactory.getLogger(V4l4jDriver.class);

	/**
	 * Initialize customized V4L4J libraries.
	 */
	static {
		V4L4J.init();
	}

	@Override
	public List getDevices() {

		List devices = new ArrayList();
		File[] vfiles = NixVideoDevUtils.getVideoFiles();

		if (LOG.isDebugEnabled()) {
			for (File vfile : vfiles) {
				LOG.debug("Video file detected {}", vfile);
			}
		}

		for (File vfile : vfiles) {
			devices.add(new V4l4jDevice(vfile));
		}

		return devices;
	}

	@Override
	public boolean isThreadSafe() {
		return false;
	}

	@Override
	public String toString() {
		return getClass().getSimpleName();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy