Package edu.wpi.grip.core.sources
Class CameraSource
- java.lang.Object
-
- edu.wpi.grip.core.Source
-
- edu.wpi.grip.core.sources.CameraSource
-
- All Implemented Interfaces:
com.google.common.util.concurrent.Service
,RestartableService
public class CameraSource extends Source implements RestartableService
Provides a way to generate a constantly updatedopencv_core.Mat
from a camera.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
CameraSource.Factory
static interface
CameraSource.FrameGrabberFactory
Allows for the creation of a frame grabber using either a device number or URL string address.static class
CameraSource.FrameGrabberFactoryImpl
-
Nested classes/interfaces inherited from class edu.wpi.grip.core.Source
Source.SourceFactory, Source.SourceFactoryImpl
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
DEFAULT_IP_CAMERA_PATH
The path that Axis cameras stream MJPEG videos from.-
Fields inherited from interface edu.wpi.grip.core.util.service.RestartableService
VALID_START_STATES
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addListener(com.google.common.util.concurrent.Service.Listener listener, java.util.concurrent.Executor executor)
void
awaitRunning()
void
awaitRunning(long timeout, java.util.concurrent.TimeUnit unit)
void
awaitTerminated()
void
awaitTerminated(long timeout, java.util.concurrent.TimeUnit unit)
java.util.List<OutputSocket>
createOutputSockets()
java.lang.Throwable
failureCause()
java.lang.String
getName()
This is used by the GUI to distinguish different sources.java.util.Properties
getProperties()
This is used for serialization/deserialization.void
initialize()
Initializes the source.boolean
isRunning()
void
onSourceRemovedEvent(SourceRemovedEvent event)
CameraSource
startAsync()
Starts the service that runs the camera source.com.google.common.util.concurrent.Service.State
state()
void
stopAndAwait()
void
stopAndAwait(long timeout, java.util.concurrent.TimeUnit unit)
CameraSource
stopAsync()
Stops the service that is running camera source.protected boolean
updateOutputSockets()
This method will check if there are any pending updates to output sockets.-
Methods inherited from class edu.wpi.grip.core.Source
getExceptionWitness, getOutputSockets, initializeSafely, toString
-
-
-
-
Field Detail
-
DEFAULT_IP_CAMERA_PATH
public static final java.lang.String DEFAULT_IP_CAMERA_PATH
The path that Axis cameras stream MJPEG videos from. Although any URL can be suppliedCameraSource.Factory.create(String)
, allowing this to work with basically any network video stream, this default path allows the Axis M1011 cameras used in FRC to work when only an IP address is supplied.- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from class:Source
This is used by the GUI to distinguish different sources. For example,ImageFileSource
returns the filename of the image.
-
createOutputSockets
public java.util.List<OutputSocket> createOutputSockets()
- Specified by:
createOutputSockets
in classSource
-
updateOutputSockets
protected boolean updateOutputSockets()
Description copied from class:Source
This method will check if there are any pending updates to output sockets. If there are any, update the sockets and then return true. If there are no updates this function should return false.- Specified by:
updateOutputSockets
in classSource
- Returns:
- true if there are updates ready to be moved into the socket.
-
getProperties
public java.util.Properties getProperties()
Description copied from class:Source
This is used for serialization/deserialization.- Specified by:
getProperties
in classSource
- Returns:
- A
Properties
containing data that can be used to re-create this source.
-
initialize
public void initialize()
Description copied from class:Source
Initializes the source. This should not try to handle initialization exceptions. Instead, theSource.initializeSafely()
should report the problem with initializing to the exception witness.- Specified by:
initialize
in classSource
-
startAsync
public CameraSource startAsync()
Starts the service that runs the camera source.- Specified by:
startAsync
in interfaceRestartableService
- Specified by:
startAsync
in interfacecom.google.common.util.concurrent.Service
- Returns:
- this
-
isRunning
public boolean isRunning()
- Specified by:
isRunning
in interfacecom.google.common.util.concurrent.Service
-
stopAsync
public CameraSource stopAsync()
Stops the service that is running camera source.- Specified by:
stopAsync
in interfaceRestartableService
- Specified by:
stopAsync
in interfacecom.google.common.util.concurrent.Service
- Returns:
- this
-
stopAndAwait
public void stopAndAwait()
- Specified by:
stopAndAwait
in interfaceRestartableService
-
stopAndAwait
public void stopAndAwait(long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.TimeoutException
- Specified by:
stopAndAwait
in interfaceRestartableService
- Throws:
java.util.concurrent.TimeoutException
-
awaitRunning
public void awaitRunning()
- Specified by:
awaitRunning
in interfacecom.google.common.util.concurrent.Service
-
awaitRunning
public void awaitRunning(long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.TimeoutException
- Specified by:
awaitRunning
in interfacecom.google.common.util.concurrent.Service
- Throws:
java.util.concurrent.TimeoutException
-
awaitTerminated
public void awaitTerminated()
- Specified by:
awaitTerminated
in interfacecom.google.common.util.concurrent.Service
-
awaitTerminated
public void awaitTerminated(long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.TimeoutException
- Specified by:
awaitTerminated
in interfacecom.google.common.util.concurrent.Service
- Throws:
java.util.concurrent.TimeoutException
-
failureCause
public java.lang.Throwable failureCause()
- Specified by:
failureCause
in interfacecom.google.common.util.concurrent.Service
-
addListener
public void addListener(com.google.common.util.concurrent.Service.Listener listener, java.util.concurrent.Executor executor)
- Specified by:
addListener
in interfacecom.google.common.util.concurrent.Service
-
state
public com.google.common.util.concurrent.Service.State state()
- Specified by:
state
in interfacecom.google.common.util.concurrent.Service
-
onSourceRemovedEvent
public void onSourceRemovedEvent(SourceRemovedEvent event) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException, java.io.IOException
- Throws:
java.lang.InterruptedException
java.util.concurrent.TimeoutException
java.io.IOException
-
-