edu.wpi.first.wpilibj

## Class CameraServer

- java.lang.Object
- - edu.wpi.first.wpilibj.CameraServer

-     public class CameraServer
      extends java.lang.Object

  Singleton class for creating and keeping camera servers. Also publishes camera information to NetworkTables.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `kBasePort`
    `static int` | `kSize160x120` Deprecated.
    `static int` | `kSize320x240` Deprecated.
    `static int` | `kSize640x480` Deprecated.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `AxisCamera` | `addAxisCamera(java.lang.String host)` Adds an Axis IP camera.
    `AxisCamera` | `addAxisCamera(java.lang.String[] hosts)` Adds an Axis IP camera.
    `AxisCamera` | `addAxisCamera(java.lang.String name, java.lang.String host)` Adds an Axis IP camera.
    `AxisCamera` | `addAxisCamera(java.lang.String name, java.lang.String[] hosts)` Adds an Axis IP camera.
    `void` | `addCamera(VideoSource camera)` Adds an already created camera.
    `MjpegServer` | `addServer(java.lang.String name)` Adds a MJPEG server at the next available port.
    `MjpegServer` | `addServer(java.lang.String name, int port)` Adds a MJPEG server.
    `void` | `addServer(VideoSink server)` Adds an already created server.
    `static CameraServer` | `getInstance()` Get the CameraServer instance.
    `VideoSink` | `getServer()` Get server for the primary camera feed.
    `VideoSink` | `getServer(java.lang.String name)` Gets a server by name.
    `CvSink` | `getVideo()` Get OpenCV access to the primary camera feed.
    `CvSink` | `getVideo(java.lang.String name)` Get OpenCV access to the specified camera.
    `CvSink` | `getVideo(VideoSource camera)` Get OpenCV access to the specified camera.
    `CvSource` | `putVideo(java.lang.String name, int width, int height)` Create a MJPEG stream with OpenCV input.
    `void` | `removeCamera(java.lang.String name)` Removes a camera by name.
    `void` | `removeServer(java.lang.String name)` Removes a server by name.
    `UsbCamera` | `startAutomaticCapture()` Start automatically capturing images to send to the dashboard.
    `UsbCamera` | `startAutomaticCapture(int dev)` Start automatically capturing images to send to the dashboard.
    `UsbCamera` | `startAutomaticCapture(java.lang.String name, int dev)` Start automatically capturing images to send to the dashboard.
    `UsbCamera` | `startAutomaticCapture(java.lang.String name, java.lang.String path)` Start automatically capturing images to send to the dashboard.
    `void` | `startAutomaticCapture(VideoSource camera)` Start automatically capturing images to send to the dashboard from an existing camera.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### kBasePort

          public static final int kBasePort

      See Also:
        Constant Field Values

    - #### kSize640x480

          @Deprecated
          public static final int kSize640x480

      Deprecated.
      See Also:
        Constant Field Values

    - #### kSize320x240

          @Deprecated
          public static final int kSize320x240

      Deprecated.
      See Also:
        Constant Field Values

    - #### kSize160x120

          @Deprecated
          public static final int kSize160x120

      Deprecated.
      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getInstance

          public static CameraServer getInstance()

      Get the CameraServer instance.

    - #### startAutomaticCapture

          public UsbCamera startAutomaticCapture()

      Start automatically capturing images to send to the dashboard.

      You should call this method to see a camera feed on the dashboard. If you also want to perform vision processing on the roboRIO, use getVideo() to get access to the camera images.

      The first time this overload is called, it calls `startAutomaticCapture(int)` with device 0, creating a camera named "USB Camera 0". Subsequent calls increment the device number (e.g. 1, 2, etc).

    - #### startAutomaticCapture

          public UsbCamera startAutomaticCapture(int dev)

      Start automatically capturing images to send to the dashboard.

      This overload calls `startAutomaticCapture(String, int)` with a name of "USB Camera {dev}".

      Parameters:
        `dev` - The device number of the camera interface

    - #### startAutomaticCapture

          public UsbCamera startAutomaticCapture(java.lang.String name,
                                                 int dev)

      Start automatically capturing images to send to the dashboard.
      Parameters:
        `name` - The name to give the camera
        `dev` - The device number of the camera interface

    - #### startAutomaticCapture

          public UsbCamera startAutomaticCapture(java.lang.String name,
                                                 java.lang.String path)

      Start automatically capturing images to send to the dashboard.
      Parameters:
        `name` - The name to give the camera
        `path` - The device path (e.g. "/dev/video0") of the camera

    - #### startAutomaticCapture

          public void startAutomaticCapture(VideoSource camera)

      Start automatically capturing images to send to the dashboard from an existing camera.
      Parameters:
        `camera` - Camera

    - #### addAxisCamera

          public AxisCamera addAxisCamera(java.lang.String host)

      Adds an Axis IP camera.

      This overload calls `addAxisCamera(String, String)` with name "Axis Camera".

      Parameters:
        `host` - Camera host IP or DNS name (e.g. "10.x.y.11")

    - #### addAxisCamera

          public AxisCamera addAxisCamera(java.lang.String[] hosts)

      Adds an Axis IP camera.

      This overload calls `addAxisCamera(String, String[])` with name "Axis Camera".

      Parameters:
        `hosts` - Array of Camera host IPs/DNS names

    - #### addAxisCamera

          public AxisCamera addAxisCamera(java.lang.String name,
                                          java.lang.String host)

      Adds an Axis IP camera.
      Parameters:
        `name` - The name to give the camera
        `host` - Camera host IP or DNS name (e.g. "10.x.y.11")

    - #### addAxisCamera

          public AxisCamera addAxisCamera(java.lang.String name,
                                          java.lang.String[] hosts)

      Adds an Axis IP camera.
      Parameters:
        `name` - The name to give the camera
        `hosts` - Array of Camera host IPs/DNS names

    - #### getVideo

          public CvSink getVideo()

      Get OpenCV access to the primary camera feed. This allows you to get images from the camera for image processing on the roboRIO.

      This is only valid to call after a camera feed has been added with startAutomaticCapture() or addServer().

    - #### getVideo

          public CvSink getVideo(VideoSource camera)

      Get OpenCV access to the specified camera. This allows you to get images from the camera for image processing on the roboRIO.
      Parameters:
        `camera` - Camera (e.g. as returned by startAutomaticCapture).

    - #### getVideo

          public CvSink getVideo(java.lang.String name)

      Get OpenCV access to the specified camera. This allows you to get images from the camera for image processing on the roboRIO.
      Parameters:
        `name` - Camera name

    - #### putVideo

          public CvSource putVideo(java.lang.String name,
                                   int width,
                                   int height)

      Create a MJPEG stream with OpenCV input. This can be called to pass custom annotated images to the dashboard.
      Parameters:
        `name` - Name to give the stream
        `width` - Width of the image being sent
        `height` - Height of the image being sent

    - #### addServer

          public MjpegServer addServer(java.lang.String name)

      Adds a MJPEG server at the next available port.
      Parameters:
        `name` - Server name

    - #### addServer

          public MjpegServer addServer(java.lang.String name,
                                       int port)

      Adds a MJPEG server.
      Parameters:
        `name` - Server name

    - #### addServer

          public void addServer(VideoSink server)

      Adds an already created server.
      Parameters:
        `server` - Server

    - #### removeServer

          public void removeServer(java.lang.String name)

      Removes a server by name.
      Parameters:
        `name` - Server name

    - #### getServer

          public VideoSink getServer()

      Get server for the primary camera feed.

      This is only valid to call after a camera feed has been added with startAutomaticCapture() or addServer().

    - #### getServer

          public VideoSink getServer(java.lang.String name)

      Gets a server by name.
      Parameters:
        `name` - Server name

    - #### addCamera

          public void addCamera(VideoSource camera)

      Adds an already created camera.
      Parameters:
        `camera` - Camera

    - #### removeCamera

          public void removeCamera(java.lang.String name)

      Removes a camera by name.
      Parameters:
        `name` - Camera name