Update Camera templates to make C++ and Java more similar.

Include delays and template code from other examples to show how to use
these examples in a full robot program. Change Java example in example
finder to Simple Vision to match C++. Add comments about how to find cam
number and change default to cam0.

Change-Id: I85846ccfaf016c538a750b057a7fd766cdff9447
This commit is contained in:
Joe Ross
2014-12-27 20:48:10 -08:00
committed by Brad Miller
parent a6aef54ef4
commit 0368322385
6 changed files with 25 additions and 13 deletions

View File

@@ -7,6 +7,7 @@ import com.ni.vision.NIVision.ShapeMode;
import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Timer;
/**
* This is a demo program showing the use of the NIVision class to do vision processing.
@@ -22,10 +23,8 @@ public class Robot extends SampleRobot {
frame = NIVision.imaqCreateImage(NIVision.ImageType.IMAGE_RGB, 0);
/**
* the camera name (ex "cam1") can be found through the roborio web interface
*/
session = NIVision.IMAQdxOpenCamera("cam1",
// the camera name (ex "cam0") can be found through the roborio web interface
session = NIVision.IMAQdxOpenCamera("cam0",
NIVision.IMAQdxCameraControlMode.CameraControlModeController);
NIVision.IMAQdxConfigureGrab(session);
}
@@ -46,6 +45,9 @@ public class Robot extends SampleRobot {
DrawMode.DRAW_VALUE, ShapeMode.SHAPE_OVAL, 0.0f);
CameraServer.getInstance().setImage(frame);
/** robot code here! **/
Timer.delay(0.005); // wait for a motor update time
}
NIVision.IMAQdxStopAcquisition(session);
}

View File

@@ -2,6 +2,7 @@ package $package;
import edu.wpi.first.wpilibj.CameraServer;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Timer;
/**
* This is a demo program showing the use of the CameraServer class.
@@ -15,6 +16,8 @@ public class Robot extends SampleRobot {
public Robot() {
server = CameraServer.getInstance();
server.setQuality(50);
//the camera name (ex "cam0") can be found through the roborio web interface
server.startAutomaticCapture("cam0");
}
/**
@@ -23,10 +26,9 @@ public class Robot extends SampleRobot {
*/
public void operatorControl() {
server.startAutomaticCapture("cam1");
while (isOperatorControl() && isEnabled()) {
/** robot code here! **/
Timer.delay(0.005); // wait for a motor update time
}
}

View File

@@ -294,7 +294,7 @@
</example>
<example>
<name>Quick Vision</name>
<name>Simple Vision</name>
<description>Demonstrate the use of the CameraServer class to stream from a USB Webcam without processing the images.</description>
<tags>
<tag>Vision</tag>