Skip to content

Commit 7fb1ad0

Browse files
committed
Use the default path for Axis M1011 cameras if none is specified
Closes #221
1 parent 98aa278 commit 7fb1ad0

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

core/src/main/java/edu/wpi/grip/core/sources/CameraSource.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
@XStreamAlias(value = "grip:Camera")
3131
public class CameraSource extends Source implements StartStoppable {
3232

33+
/**
34+
* The path that Axis cameras stream MJPEG videos from. Although any URL can be supplied
35+
* {@link CameraSource.Factory#create(String)}, allowing this to work with basically any network video stream, this
36+
* default path allows the Axis M1011 cameras used in FRC to work when only an IP address is supplied.
37+
*/
38+
public final static String DEFAULT_IP_CAMERA_PATH = "/mjpg/video.mjpg";
39+
3340
private final static String DEVICE_NUMBER_PROPERTY = "deviceNumber";
3441
private final static String ADDRESS_PROPERTY = "address";
3542
private static Logger logger = Logger.getLogger(CameraSource.class.getName());
@@ -75,6 +82,11 @@ public FrameGrabber create(int deviceNumber) {
7582
}
7683

7784
public FrameGrabber create(String addressProperty) throws MalformedURLException {
85+
// If no path was specified in the URL (ie: it was something like http://10.1.90.11/), use the default path
86+
// for Axis M1011 cameras.
87+
if (new URL(addressProperty).getPath().length() <= 1) {
88+
addressProperty += DEFAULT_IP_CAMERA_PATH;
89+
}
7890
return new IPCameraFrameGrabber(addressProperty);
7991
}
8092
}

0 commit comments

Comments
 (0)