Class CvSource

All Implemented Interfaces:
AutoCloseable

public class CvSource
extends ImageSource
A source that represents a video camera. These sources require the WPILib OpenCV builds. For an alternate OpenCV, see the documentation how to build your own with RawSource.
  • Constructor Details

    • CvSource

      public CvSource​(String name, VideoMode mode)
      Create an OpenCV source.
      Parameters:
      name - Source name (arbitrary unique identifier)
      mode - Video mode being generated
    • CvSource

      public CvSource​(String name, PixelFormat pixelFormat, int width, int height, int fps)
      Create an OpenCV source.
      Parameters:
      name - Source name (arbitrary unique identifier)
      pixelFormat - Pixel format
      width - width
      height - height
      fps - fps
  • Method Details

    • putFrame

      public void putFrame​(Mat image)
      Put an OpenCV image and notify sinks

      The image format is guessed from the number of channels. The channel mapping is as follows. 1: kGray 2: kYUYV 3: BGR 4: BGRA Any other channel numbers will throw an error. If your image is an in alternate format, use the overload that takes a PixelFormat.

      Parameters:
      image - OpenCV Image
    • putFrame

      public void putFrame​(Mat image, PixelFormat format, boolean skipVerification)
      Put an OpenCV image and notify sinks.

      The format of the Mat must match the PixelFormat. You will corrupt memory if they dont. With skipVerification false, we will verify the number of channels matches the pixel format. If skipVerification is true, this step is skipped and is passed straight through.

      Parameters:
      image - OpenCV image
      format - The pixel format of the image
      skipVerification - skip verifying pixel format