Package com.pocolifo.robobase.vision
Class Webcam
- java.lang.Object
-
- com.pocolifo.robobase.vision.Webcam
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public class Webcam extends java.lang.Object implements java.lang.AutoCloseable
Abstracts away certain parts ofOpenCvCamera
.
-
-
Field Summary
Fields Modifier and Type Field Description com.qualcomm.robotcore.hardware.HardwareMap
hardwareMap
TheHardwareMap
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 aWebcam
.Webcam(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, org.firstinspires.ftc.robotcore.external.hardware.camera.WebcamName webcamDevice)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearPipeline()
Unsets the webcam pipeline; no data will be able to be processed since there is no pipeline active.void
close()
Closes the camera.AbstractResultCvPipeline<?>
getPipeline()
Gets the current active pipeline of the webcam.void
open(AbstractResultCvPipeline<?> pipeline)
Opens the camera.void
setPipeline(AbstractResultCvPipeline<?> pipeline)
Sets the pipeline for the webcam which can process the data stream coming in from the webcam.
-
-
-
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 aWebcam
.- Parameters:
hardwareMap
- TheHardwareMap
that has the webcam in it.name
- The name of the webcam in theHardwareMap
.
-
-
Method Detail
-
open
public void open(AbstractResultCvPipeline<?> pipeline) throws java.lang.RuntimeException
Opens the camera. For this to be of any use, callsetPipeline(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 interfacejava.lang.AutoCloseable
- Throws:
java.lang.Exception
- If an error occurred while closing the camera.
-
-