001/*----------------------------------------------------------------------------*/
002/* Copyright (c) 2016-2018 FIRST. 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/**
011 * A source that represents a USB camera.
012 */
013public class UsbCamera extends VideoCamera {
014  /**
015   * Create a source for a USB camera based on device number.
016   * @param name Source name (arbitrary unique identifier)
017   * @param dev Device number (e.g. 0 for /dev/video0)
018   */
019  public UsbCamera(String name, int dev) {
020    super(CameraServerJNI.createUsbCameraDev(name, dev));
021  }
022
023  /**
024   * Create a source for a USB camera based on device path.
025   * @param name Source name (arbitrary unique identifier)
026   * @param path Path to device (e.g. "/dev/video0" on Linux)
027   */
028  public UsbCamera(String name, String path) {
029    super(CameraServerJNI.createUsbCameraPath(name, path));
030  }
031
032  /**
033   * Enumerate USB cameras on the local system.
034   * @return Vector of USB camera information (one for each camera)
035   */
036  public static UsbCameraInfo[] enumerateUsbCameras() {
037    return CameraServerJNI.enumerateUsbCameras();
038  }
039
040  /**
041   * Get the path to the device.
042   */
043  public String getPath() {
044    return CameraServerJNI.getUsbCameraPath(m_handle);
045  }
046}