001/*----------------------------------------------------------------------------*/ 002/* Copyright (c) FIRST 2016. All Rights Reserved. */ 003/* Open Source Software - may be modified and shared by FRC teams. The code */ 004/* must be accompanied by the FIRST BSD license file in the root directory of */ 005/* the project. */ 006/*----------------------------------------------------------------------------*/ 007 008package edu.wpi.cscore; 009 010/// A source that represents a USB camera. 011public class UsbCamera extends VideoCamera { 012 /// Create a source for a USB camera based on device number. 013 /// @param name Source name (arbitrary unique identifier) 014 /// @param dev Device number (e.g. 0 for /dev/video0) 015 public UsbCamera(String name, int dev) { 016 super(CameraServerJNI.createUsbCameraDev(name, dev)); 017 } 018 019 /// Create a source for a USB camera based on device path. 020 /// @param name Source name (arbitrary unique identifier) 021 /// @param path Path to device (e.g. "/dev/video0" on Linux) 022 public UsbCamera(String name, String path) { 023 super(CameraServerJNI.createUsbCameraPath(name, path)); 024 } 025 026 /// Enumerate USB cameras on the local system. 027 /// @return Vector of USB camera information (one for each camera) 028 public static UsbCameraInfo[] enumerateUsbCameras() { 029 return CameraServerJNI.enumerateUsbCameras(); 030 } 031 032 /// Get the path to the device. 033 public String getPath() { 034 return CameraServerJNI.getUsbCameraPath(m_handle); 035 } 036}