-Changed application to display image source at the top of the window.
-Removed the extra windows to show intermediate stages when not in debug mode.
Interestingly, this improved performance significantly.
-Modified slider listener so that it (hopefully) doesn't cause any more segfaults.
-Hid all the calibration controls away in a separate calibration window.
They are accessed by a button on the main display.
I also added labels to each of the sliders.
-Application now takes the IP address of the atom as a command-line argument.
-Code now actually uses result sender, which I had forgot to do last time.
-I made a small modification to Brian's code which reduced the application's
average consumption of RAM from two gigabytes to eight hundred megabytes.
git-svn-id: https://robotics.mvla.net/svn/frc971/2013/trunk/src@4151 f308d9b7-e957-4cde-b6ac-9a88185e7312
diff --git a/971CV/src/org/frc971/HTTPClient.java b/971CV/src/org/frc971/HTTPClient.java
index cc694ef..96308a1 100644
--- a/971CV/src/org/frc971/HTTPClient.java
+++ b/971CV/src/org/frc971/HTTPClient.java
@@ -24,9 +24,9 @@
/** whether or not to print debug messages to stdout. */
private final static boolean LOCAL_DEBUG = false;
- private SocketChannel sock;
+ private String atomIP;
- private final String ATOM_IP = "192.168.0.137";
+ private SocketChannel sock;
private ChannelImageGetter cgetter;
@@ -41,11 +41,12 @@
/** the constructor, initializes connection, and sets up aos getter.
* @throws IOException */
- public HTTPClient() throws IOException {
+ public HTTPClient(String atomIP) throws IOException {
//Initialize socket connection to robot
+ this.atomIP = atomIP;
sock = SocketChannel.open();
- WriteDebug("Connecting to server at " + ATOM_IP);
- sock.connect(new InetSocketAddress(ATOM_IP, 9714));
+ WriteDebug("Connecting to server at " + atomIP);
+ sock.connect(new InetSocketAddress(atomIP, 9714));
sock.configureBlocking(false);
//Write headers
//HTTPStreamer does not actually use the headers, so we can just write terminating chars.
@@ -63,10 +64,14 @@
public ImageWithTimestamp GetFrame() {
ImageWithTimestamp final_image = new ImageWithTimestamp();
//Use Brian's code to extract an image and timestamp from raw server data.
- ByteBuffer binary_image = cgetter.getJPEG();
+ ByteBuffer binaryImage = cgetter.getJPEG();
+ if (binaryImage == null) {
+ Messages.severe("Could not parse data from robot. See the log for details.");
+ return null;
+ }
//Decode ByteBuffer into an IplImage
- byte[] b = new byte[binary_image.remaining()];
- binary_image.get(b);
+ byte[] b = new byte[binaryImage.remaining()];
+ binaryImage.get(b);
try {
InputStream iis = new ByteArrayInputStream(b);
BufferedImage bImageFromConvert = ImageIO.read(iis);
@@ -80,4 +85,9 @@
return null;
}
}
+
+ /** Gets the name to display at the top of the image window. */
+ public String GetName() {
+ return atomIP;
+ }
}