mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
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:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<name>Simple vision program</name>
|
||||
<name>Simple Vision</name>
|
||||
<description>The minimal program to acquire images from an attached USB camera on the robot
|
||||
and send them to the dashboard.</description>
|
||||
<tags>
|
||||
@@ -298,7 +298,7 @@
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<name>Intermediate vision</name>
|
||||
<name>Intermediate Vision</name>
|
||||
<description>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.
|
||||
|
||||
Reference in New Issue
Block a user