001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.cscore;
006
007/** A base class for single image reading sinks. */
008public abstract class ImageSink extends VideoSink {
009  /**
010   * Constructs an ImageSink.
011   *
012   * @param handle The image sink handle.
013   */
014  protected ImageSink(int handle) {
015    super(handle);
016  }
017
018  /**
019   * Set sink description.
020   *
021   * @param description Description
022   */
023  public void setDescription(String description) {
024    CameraServerJNI.setSinkDescription(m_handle, description);
025  }
026
027  /**
028   * Get error string. Call this if WaitForFrame() returns 0 to determine what the error is.
029   *
030   * @return Error string.
031   */
032  public String getError() {
033    return CameraServerJNI.getSinkError(m_handle);
034  }
035
036  /**
037   * Enable or disable getting new frames. Disabling will cause processFrame (for callback-based
038   * CvSinks) to not be called and WaitForFrame() to not return. This can be used to save processor
039   * resources when frames are not needed.
040   *
041   * @param enabled Enable to get new frames.
042   */
043  public void setEnabled(boolean enabled) {
044    CameraServerJNI.setSinkEnabled(m_handle, enabled);
045  }
046}