diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/IntermediateVision/src/Robot.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/IntermediateVision/src/Robot.cpp index b6f101264f..fc874a1031 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/IntermediateVision/src/Robot.cpp +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/IntermediateVision/src/Robot.cpp @@ -14,7 +14,7 @@ public: void RobotInit() override { // create an image frame = imaqCreateImage(IMAQ_IMAGE_RGB, 0); - // open the camera + //the camera name (ex "cam0") can be found through the roborio web interface imaqError = IMAQdxOpenCamera("cam0", IMAQdxCameraControlModeController, &session); if(imaqError != IMAQdxErrorSuccess) { DriverStation::ReportError("IMAQdxOpenCamera error: " + std::to_string((long)imaqError) + "\n"); @@ -39,6 +39,7 @@ public: imaqDrawShapeOnImage(frame, frame, { 10, 10, 100, 100 }, DrawMode::IMAQ_DRAW_VALUE, ShapeMode::IMAQ_SHAPE_OVAL, 0.0f); CameraServer::GetInstance()->SetImage(frame); } + Wait(0.005); // wait for a motor update time } // stop image acquisition IMAQdxStopAcquisition(session); diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/QuickVision/src/Robot.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/QuickVision/src/Robot.cpp index 00fdffd3bb..9ee47c0829 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/QuickVision/src/Robot.cpp +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/QuickVision/src/Robot.cpp @@ -10,11 +10,18 @@ class QuickVisionRobot : public SampleRobot { public: void RobotInit() override { - CameraServer::GetInstance()->SetQuality(75); - CameraServer::GetInstance()->StartAutomaticCapture(); + CameraServer::GetInstance()->SetQuality(50); + //the camera name (ex "cam0") can be found through the roborio web interface + CameraServer::GetInstance()->StartAutomaticCapture("cam0"); } - void OperatorControl() override { + void OperatorControl() + { + while (IsOperatorControl() && IsEnabled()) + { + /** robot code here! **/ + Wait(0.005); // wait for a motor update time + } } }; diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/examples.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/examples.xml index 51076301d8..1013b57ed3 100644 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/examples.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/examples.xml @@ -281,7 +281,7 @@ - Simple vision program + Simple Vision The minimal program to acquire images from an attached USB camera on the robot and send them to the dashboard. @@ -298,7 +298,7 @@ - Intermediate vision + Intermediate Vision An example program that acquires images from an attached USB camera and adds some annotation to the image as you might do for showing operators the result of some image recognition, and sends it to the dashboard for display. diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/IntermediateVision/src/org/usfirst/frc/team190/robot/Robot.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/IntermediateVision/src/org/usfirst/frc/team190/robot/Robot.java index 479c6f1617..f26661f198 100755 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/IntermediateVision/src/org/usfirst/frc/team190/robot/Robot.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/IntermediateVision/src/org/usfirst/frc/team190/robot/Robot.java @@ -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); } diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/QuickVision/src/org/usfirst/frc/team190/robot/Robot.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/QuickVision/src/org/usfirst/frc/team190/robot/Robot.java index d224991816..bc7835bfd1 100755 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/QuickVision/src/org/usfirst/frc/team190/robot/Robot.java +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/QuickVision/src/org/usfirst/frc/team190/robot/Robot.java @@ -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 } } diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/examples.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/examples.xml index 87b8a22df8..8a535b38d8 100755 --- a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/examples.xml +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/examples.xml @@ -294,7 +294,7 @@ - Quick Vision + Simple Vision Demonstrate the use of the CameraServer class to stream from a USB Webcam without processing the images. Vision