diff --git a/wpilibc/athena/include/CameraServer.h b/wpilibc/athena/include/CameraServer.h index d413ad232c..d5dcb2f88c 100644 --- a/wpilibc/athena/include/CameraServer.h +++ b/wpilibc/athena/include/CameraServer.h @@ -44,16 +44,20 @@ class CameraServer : public ErrorBase { * If you also want to perform vision processing on the roboRIO, use * getVideo() to get access to the camera images. * - * This overload calls {@link #startAutomaticCapture(int)} with device 0. + * This overload calls {@link #StartAutomaticCapture(int)} with device 0, + * creating a camera named "USB Camera 0". */ - cs::USBCamera StartAutomaticCapture(); + cs::UsbCamera StartAutomaticCapture(); /** * Start automatically capturing images to send to the dashboard. * + *
This overload calls {@link #StartAutomaticCapture(String, int)} with
+ * a name of "USB Camera {dev}".
+ *
* @param dev The device number of the camera interface
*/
- cs::USBCamera StartAutomaticCapture(int dev);
+ cs::UsbCamera StartAutomaticCapture(int dev);
/**
* Start automatically capturing images to send to the dashboard.
@@ -61,7 +65,7 @@ class CameraServer : public ErrorBase {
* @param name The name to give the camera
* @param dev The device number of the camera interface
*/
- cs::USBCamera StartAutomaticCapture(llvm::StringRef name, int dev);
+ cs::UsbCamera StartAutomaticCapture(llvm::StringRef name, int dev);
/**
* Start automatically capturing images to send to the dashboard.
@@ -69,7 +73,7 @@ class CameraServer : public ErrorBase {
* @param name The name to give the camera
* @param path The device path (e.g. "/dev/video0") of the camera
*/
- cs::USBCamera StartAutomaticCapture(llvm::StringRef name,
+ cs::UsbCamera StartAutomaticCapture(llvm::StringRef name,
llvm::StringRef path);
/**
@@ -97,6 +101,14 @@ class CameraServer : public ErrorBase {
*/
cs::CvSink GetVideo(const cs::VideoSource& camera);
+ /**
+ * Get OpenCV access to the specified camera. This allows you to get
+ * images from the camera for image processing on the roboRIO.
+ *
+ * @param name Camera name
+ */
+ cs::CvSink GetVideo(llvm::StringRef name);
+
/**
* Create a MJPEG stream with OpenCV input. This can be called to pass custom
* annotated images to the dashboard.
@@ -112,14 +124,14 @@ class CameraServer : public ErrorBase {
*
* @param name Server name
*/
- cs::MJPEGServer AddServer(llvm::StringRef name);
+ cs::MjpegServer AddServer(llvm::StringRef name);
/**
* Adds a MJPEG server.
*
* @param name Server name
*/
- cs::MJPEGServer AddServer(llvm::StringRef name, int port);
+ cs::MjpegServer AddServer(llvm::StringRef name, int port);
/**
* Adds an already created server.
@@ -154,7 +166,7 @@ class CameraServer : public ErrorBase {
* the correct mode, or set it directly on a camera and call the appropriate
* StartAutomaticCapture method.
*
- * @deprecated Use SetResolution on the USBCamera returned by
+ * @deprecated Use SetResolution on the UsbCamera returned by
* StartAutomaticCapture() instead.
* @param size The size to use
*/
diff --git a/wpilibc/athena/src/CameraServer.cpp b/wpilibc/athena/src/CameraServer.cpp
index 352a730aa8..5ffae00a3f 100644
--- a/wpilibc/athena/src/CameraServer.cpp
+++ b/wpilibc/athena/src/CameraServer.cpp
@@ -24,14 +24,14 @@ static llvm::StringRef MakeSourceValue(CS_Source source,
CS_Status status = 0;
buf.clear();
switch (cs::GetSourceKind(source, &status)) {
- case cs::VideoSource::kUSB: {
+ case cs::VideoSource::kUsb: {
llvm::StringRef prefix{"usb:"};
buf.append(prefix.begin(), prefix.end());
- auto path = cs::GetUSBCameraPath(source, &status);
+ auto path = cs::GetUsbCameraPath(source, &status);
buf.append(path.begin(), path.end());
break;
}
- case cs::VideoSource::kHTTP: {
+ case cs::VideoSource::kHttp: {
llvm::StringRef prefix{"ip:"};
buf.append(prefix.begin(), prefix.end());
// TODO
@@ -64,8 +64,8 @@ void CameraServer::UpdateStreamValues() {
// Over all the sinks...
for (const auto& i : m_sinks) {
CS_Status status = 0;
- // Ignore all but MJPEGServer
- if (i.second.GetKind() != cs::VideoSink::kMJPEG) continue;
+ // Ignore all but MjpegServer
+ if (i.second.GetKind() != cs::VideoSink::kMjpeg) continue;
CS_Sink sink = i.second.GetHandle();
// Get the source's subtable (if none exists, we're done)
@@ -74,11 +74,11 @@ void CameraServer::UpdateStreamValues() {
if (!table) continue;
// Get port
- int port = cs::GetMJPEGServerPort(sink, &status);
+ int port = cs::GetMjpegServerPort(sink, &status);
// Generate values
std::vector This overload calls {@link #startAutomaticCapture(int)} with device 0.
+ * This overload calls {@link #startAutomaticCapture(int)} with device 0,
+ * creating a camera named "USB Camera 0".
*/
- public USBCamera startAutomaticCapture() {
+ public UsbCamera startAutomaticCapture() {
return startAutomaticCapture(0);
}
/**
* Start automatically capturing images to send to the dashboard.
*
+ * This overload calls {@link #startAutomaticCapture(String, int)} with
+ * a name of "USB Camera {dev}".
+ *
* @param dev The device number of the camera interface
*/
- public USBCamera startAutomaticCapture(int dev) {
- USBCamera camera = new USBCamera("USB Camera " + dev, dev);
+ public UsbCamera startAutomaticCapture(int dev) {
+ UsbCamera camera = new UsbCamera("USB Camera " + dev, dev);
startAutomaticCapture(camera);
return camera;
}
@@ -265,8 +269,8 @@ public class CameraServer {
* @param name The name to give the camera
* @param dev The device number of the camera interface
*/
- public USBCamera startAutomaticCapture(String name, int dev) {
- USBCamera camera = new USBCamera(name, dev);
+ public UsbCamera startAutomaticCapture(String name, int dev) {
+ UsbCamera camera = new UsbCamera(name, dev);
startAutomaticCapture(camera);
return camera;
}
@@ -277,8 +281,8 @@ public class CameraServer {
* @param name The name to give the camera
* @param path The device path (e.g. "/dev/video0") of the camera
*/
- public USBCamera startAutomaticCapture(String name, String path) {
- USBCamera camera = new USBCamera(name, path);
+ public UsbCamera startAutomaticCapture(String name, String path) {
+ UsbCamera camera = new UsbCamera(name, path);
startAutomaticCapture(camera);
return camera;
}
@@ -342,6 +346,23 @@ public class CameraServer {
return newsink;
}
+ /**
+ * Get OpenCV access to the specified camera. This allows you to get
+ * images from the camera for image processing on the roboRIO.
+ *
+ * @param name Camera name
+ */
+ public CvSink getVideo(String name) {
+ VideoSource source;
+ synchronized (this) {
+ source = m_sources.get(name);
+ if (source == null) {
+ throw new VideoException("could not find camera " + name);
+ }
+ }
+ return getVideo(source);
+ }
+
/**
* Create a MJPEG stream with OpenCV input. This can be called to pass custom
* annotated images to the dashboard.
@@ -361,7 +382,7 @@ public class CameraServer {
*
* @param name Server name
*/
- public MJPEGServer addServer(String name) {
+ public MjpegServer addServer(String name) {
int port;
synchronized (this) {
port = m_nextPort;
@@ -375,8 +396,8 @@ public class CameraServer {
*
* @param name Server name
*/
- public MJPEGServer addServer(String name, int port) {
- MJPEGServer server = new MJPEGServer(name, port);
+ public MjpegServer addServer(String name, int port) {
+ MjpegServer server = new MjpegServer(name, port);
addServer(server);
return server;
}
@@ -433,7 +454,7 @@ public class CameraServer {
* Sets the size of the image to use. Use the public kSize constants to set the correct mode, or
* set it directly on a camera and call the appropriate startAutomaticCapture method.
*
- * @deprecated Use setResolution on the USBCamera returned by startAutomaticCapture() instead.
+ * @deprecated Use setResolution on the UsbCamera returned by startAutomaticCapture() instead.
* @param size The size to use
*/
@Deprecated