mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Added vision samples
Change-Id: Ieb482d072ae15817be40477f187f081c9f7fe19f
This commit is contained in:
committed by
James Kuszmaul
parent
9ec5164075
commit
4ad8818a8a
@@ -0,0 +1,40 @@
|
||||
#include "WPILib.h"
|
||||
|
||||
/**
|
||||
* Uses IMAQdx to manually acquire a new image each frame, and annotate the image by drawing
|
||||
* a circle on it, and show it on the FRC Dashboard.
|
||||
*/
|
||||
class IntermediateVisionRobot : public SampleRobot
|
||||
{
|
||||
IMAQdxSession session;
|
||||
Image *frame;
|
||||
|
||||
public:
|
||||
void RobotInit() override {
|
||||
// create an image
|
||||
frame = imaqCreateImage(IMAQ_IMAGE_RGB, 0);
|
||||
// open the camera
|
||||
IMAQdxOpenCamera("cam1", IMAQdxCameraControlModeController, &session);
|
||||
IMAQdxConfigureGrab(session);
|
||||
}
|
||||
|
||||
void OperatorControl() override {
|
||||
// acquire images
|
||||
IMAQdxStartAcquisition(session);
|
||||
|
||||
// grab an image, draw the circle, and provide it for the camera server which will
|
||||
// in turn send it to the dashboard.
|
||||
while(IsOperatorControl() && IsEnabled()) {
|
||||
IMAQdxGrab(session, frame, true, NULL);
|
||||
|
||||
imaqDrawShapeOnImage(frame, frame, { 10, 10, 100, 100 }, DrawMode::IMAQ_DRAW_VALUE, ShapeMode::IMAQ_SHAPE_OVAL, 0.0f);
|
||||
|
||||
CameraServer::GetInstance()->SetImage(frame);
|
||||
}
|
||||
// stop image acquisition
|
||||
IMAQdxStopAcquisition(session);
|
||||
}
|
||||
};
|
||||
|
||||
START_ROBOT_CLASS(IntermediateVisionRobot);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "WPILib.h"
|
||||
|
||||
/**
|
||||
* Uses the CameraServer class to automatically capture video from a USB webcam
|
||||
* and send it to the FRC dashboard without doing any vision processing. This
|
||||
* is the easiest way to get camera images to the dashboard. Just add this to the
|
||||
* RobotInit() method in your program.
|
||||
*/
|
||||
class QuickVisionRobot : public SampleRobot
|
||||
{
|
||||
public:
|
||||
void RobotInit() override {
|
||||
CameraServer::GetInstance()->SetQuality(75);
|
||||
CameraServer::GetInstance()->StartAutomaticCapture();
|
||||
}
|
||||
|
||||
void OperatorControl() override {
|
||||
}
|
||||
};
|
||||
|
||||
START_ROBOT_CLASS(QuickVisionRobot);
|
||||
|
||||
@@ -87,7 +87,12 @@
|
||||
<description>Example programs that demonstrate the use of the various commonly used sensors on FRC robots</description>
|
||||
</tagDescription>
|
||||
|
||||
<example>
|
||||
<tagDescription>
|
||||
<name>Vision</name>
|
||||
<description>Example programs that demonstrate the use of a camera for image acquisition and processing</description>
|
||||
</tagDescription>
|
||||
|
||||
<example>
|
||||
<name>Motor Controller</name>
|
||||
<description>Demonstrate controlling a single motor with a Joystick.</description>
|
||||
<tags>
|
||||
@@ -240,8 +245,45 @@
|
||||
destination="src/Robot.cpp"></file>
|
||||
</files>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
|
||||
<example>
|
||||
<name>Simple vision program</name>
|
||||
<description>The minimal program to acquire images from an attached USB camera on the robot
|
||||
and send them to the dashboard.</description>
|
||||
<tags>
|
||||
<tag>Vision</tag>
|
||||
<tag>Complete List</tag>
|
||||
</tags>
|
||||
<packages>
|
||||
<package>src</package>
|
||||
</packages>
|
||||
<files>
|
||||
<file source="examples/QuickVision/src/Robot.cpp"
|
||||
destination="src/Robot.cpp"></file>
|
||||
</files>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<name>Getting Started</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.
|
||||
</description>
|
||||
<tags>
|
||||
<tag>Vision</tag>
|
||||
<tag>Complete List</tag>
|
||||
</tags>
|
||||
<packages>
|
||||
<package>src</package>
|
||||
</packages>
|
||||
<files>
|
||||
<file source="examples/IntermediateVision/src/Robot.cpp"
|
||||
destination="src/Robot.cpp"></file>
|
||||
</files>
|
||||
</example>
|
||||
|
||||
|
||||
<example>
|
||||
<name>GearsBot</name>
|
||||
<description>A fully functional example CommandBased program for
|
||||
WPIs GearsBot robot. This code can run on your computer if it
|
||||
|
||||
Reference in New Issue
Block a user