edu.wpi.cscore

## Class CvSink

- java.lang.Object
- - edu.wpi.cscore.VideoSink
  - - edu.wpi.cscore.CvSink

-     public class CvSink
      extends VideoSink

  A sink for user code to accept video frames as OpenCV images.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class edu.wpi.cscore.VideoSink

      `VideoSink.Kind`

  - ### Field Summary

    - ### Fields inherited from class edu.wpi.cscore.VideoSink

      `m_handle`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CvSink(java.lang.String name)` Create a sink for accepting OpenCV images.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `getError()` Get error string.
    `long` | `grabFrame(Mat image)` Wait for the next frame and get the image.
    `long` | `grabFrame(Mat image, double timeout)` Wait for the next frame and get the image.
    `long` | `grabFrameNoTimeout(Mat image)` Wait for the next frame and get the image.
    `void` | `setDescription(java.lang.String description)` Set sink description.
    `void` | `setEnabled(boolean enabled)` Enable or disable getting new frames.

    - ### Methods inherited from class edu.wpi.cscore.VideoSink

      `enumerateSinks, equals, free, getDescription, getHandle, getKind, getKindFromInt, getName, getSource, getSourceProperty, hashCode, isValid, setSource`

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

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

- - ### Constructor Detail

    - #### CvSink

          public CvSink(java.lang.String name)

      Create a sink for accepting OpenCV images. WaitForFrame() must be called on the created sink to get each new image.
      Parameters:
        `name` - Source name (arbitrary unique identifier)

  - ### Method Detail

    - #### setDescription

          public void setDescription(java.lang.String description)

      Set sink description.
      Parameters:
        `description` - Description

    - #### grabFrame

          public long grabFrame(Mat image)

      Wait for the next frame and get the image. Times out (returning 0) after 0.225 seconds. The provided image will have three 3-bit channels stored in BGR order.
      Returns:
        Frame time, or 0 on error (call GetError() to obtain the error message)

    - #### grabFrame

          public long grabFrame(Mat image,
                                double timeout)

      Wait for the next frame and get the image. Times out (returning 0) after timeout seconds. The provided image will have three 3-bit channels stored in BGR order.
      Returns:
        Frame time, or 0 on error (call GetError() to obtain the error message)

    - #### grabFrameNoTimeout

          public long grabFrameNoTimeout(Mat image)

      Wait for the next frame and get the image. May block forever. The provided image will have three 3-bit channels stored in BGR order.
      Returns:
        Frame time, or 0 on error (call GetError() to obtain the error message)

    - #### getError

          public java.lang.String getError()

      Get error string. Call this if WaitForFrame() returns 0 to determine what the error is.

    - #### setEnabled

          public void setEnabled(boolean enabled)

      Enable or disable getting new frames. Disabling will cause processFrame (for callback-based CvSinks) to not be called and WaitForFrame() to not return. This can be used to save processor resources when frames are not needed.