mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Revamp API again and start implementing C and Java wrapper shells.
This commit is contained in:
66
java/src/edu/wpi/cameraserver/VideoSource.java
Normal file
66
java/src/edu/wpi/cameraserver/VideoSource.java
Normal file
@@ -0,0 +1,66 @@
|
||||
package edu.wpi.cameraserver;
|
||||
|
||||
/// A source for video that provides a sequence of frames. Each frame may
|
||||
/// consist of multiple images (e.g. from a stereo or depth camera); these
|
||||
/// are called channels.
|
||||
public class VideoSource {
|
||||
protected VideoSource(int handle) {
|
||||
m_handle = handle;
|
||||
}
|
||||
|
||||
public synchronized void free() {
|
||||
if (m_handle != 0) {
|
||||
CameraServerJNI.releaseSource(m_handle);
|
||||
}
|
||||
m_handle = 0;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return m_handle != 0;
|
||||
}
|
||||
|
||||
/// Get the name of the source. The name is an arbitrary identifier
|
||||
/// provided when the source is created, and should be unique.
|
||||
public String getName() {
|
||||
return CameraServerJNI.getSourceName(m_handle);
|
||||
}
|
||||
|
||||
/// Get the source description. This is source-type specific.
|
||||
public String getDescription() {
|
||||
return CameraServerJNI.getSourceDescription(m_handle);
|
||||
}
|
||||
|
||||
/// Get the last time a frame was captured.
|
||||
public long getLastFrameTime() {
|
||||
return CameraServerJNI.getSourceLastFrameTime(m_handle);
|
||||
}
|
||||
|
||||
/// Get the number of channels this source provides.
|
||||
public int getNumChannels() {
|
||||
return CameraServerJNI.getSourceNumChannels(m_handle);
|
||||
}
|
||||
|
||||
/// Is the source currently connected to whatever is providing the images?
|
||||
public boolean isConnected() {
|
||||
return CameraServerJNI.isSourceConnected(m_handle);
|
||||
}
|
||||
|
||||
/// Get a property.
|
||||
/// @param name Property name
|
||||
/// @return Property contents (of type Property::kNone if no property with
|
||||
/// the given name exists)
|
||||
//public VideoProperty getProperty(String name);
|
||||
|
||||
/// Enumerate all existing sources.
|
||||
/// @return Vector of sources.
|
||||
public static VideoSource[] enumerateSources() {
|
||||
int[] handles = CameraServerJNI.enumerateSources();
|
||||
VideoSource[] rv = new VideoSource[handles.length];
|
||||
for (int i=0; i<handles.length; i++) {
|
||||
rv[i] = new VideoSource(handles[i]);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
protected int m_handle;
|
||||
}
|
||||
Reference in New Issue
Block a user