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.wpilibj.vision;
006
007import edu.wpi.first.cscore.VideoSource;
008
009/**
010 * A vision thread is a special thread that runs a vision pipeline. It is a <i>daemon</i> thread; it
011 * does not prevent the program from exiting when all other non-daemon threads have finished
012 * running.
013 *
014 * @see VisionPipeline
015 * @see VisionRunner
016 * @see Thread#setDaemon(boolean)
017 * @deprecated Replaced with edu.wpi.first.vision.VisionThread
018 */
019@Deprecated
020public class VisionThread extends Thread {
021  /**
022   * Creates a vision thread that continuously runs a {@link VisionPipeline}.
023   *
024   * @param visionRunner the runner for a vision pipeline
025   */
026  public VisionThread(VisionRunner<?> visionRunner) {
027    super(visionRunner::runForever, "WPILib Vision Thread");
028    setDaemon(true);
029  }
030
031  /**
032   * Creates a new vision thread that continuously runs the given vision pipeline. This is
033   * equivalent to {@code new VisionThread(new VisionRunner<>(videoSource, pipeline, listener))}.
034   *
035   * @param videoSource the source for images the pipeline should process
036   * @param pipeline the pipeline to run
037   * @param listener the listener to copy outputs from the pipeline after it runs
038   * @param <P> the type of the pipeline
039   */
040  public <P extends VisionPipeline> VisionThread(
041      VideoSource videoSource, P pipeline, VisionRunner.Listener<? super P> listener) {
042    this(new VisionRunner<>(videoSource, pipeline, listener));
043  }
044}