Class Webcam

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class Webcam
    extends java.lang.Object
    implements java.lang.AutoCloseable
    Abstracts away certain parts of OpenCvCamera.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      com.qualcomm.robotcore.hardware.HardwareMap hardwareMap
      The HardwareMap associated with this webcam.
      org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName webcamDevice
      The webcam device.
    • Constructor Summary

      Constructors 
      Constructor Description
      Webcam​(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, java.lang.String name)
      Initializes a Webcam.
      Webcam​(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName webcamDevice)  
    • Field Detail

      • hardwareMap

        public final com.qualcomm.robotcore.hardware.HardwareMap hardwareMap
        The HardwareMap associated with this webcam.
      • webcamDevice

        public final org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName webcamDevice
        The webcam device.
    • Constructor Detail

      • Webcam

        public Webcam​(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap,
                      org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName webcamDevice)
      • Webcam

        public Webcam​(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap,
                      java.lang.String name)
        Initializes a Webcam.
        Parameters:
        hardwareMap - The HardwareMap that has the webcam in it.
        name - The name of the webcam in the HardwareMap.
    • Method Detail

      • open

        public void open​(AbstractResultCvPipeline<?> pipeline)
                  throws java.lang.RuntimeException
        Opens the camera. For this to be of any use, call setPipeline(AbstractResultCvPipeline). Pipelines allow data from the camera to be processed. This is a blocking method. WHEN YOU'RE DONE WITH THE WEBCAM, CLOSE IT!
        Parameters:
        pipeline - The initial pipeline which will process camera input.
        Throws:
        java.lang.RuntimeException - If there was an error while opening the camera.
      • setPipeline

        public void setPipeline​(AbstractResultCvPipeline<?> pipeline)
        Sets the pipeline for the webcam which can process the data stream coming in from the webcam.
        Parameters:
        pipeline - The pipeline to use to process data.
      • clearPipeline

        public void clearPipeline()
        Unsets the webcam pipeline; no data will be able to be processed since there is no pipeline active.
      • getPipeline

        public AbstractResultCvPipeline<?> getPipeline()
        Gets the current active pipeline of the webcam.
        Returns:
        The current active pipeline.
      • close

        public void close()
                   throws java.lang.Exception
        Closes the camera. THIS SHOULD BE CALLED AFTER THE CAMERA IS UNNECESSARY TO THE PROGRAM!
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception - If an error occurred while closing the camera.