Axis camera C++ example program

Change-Id: I60a14ce91fc09831b497ccdaaa7bb1bb26c8d945
This commit is contained in:
Brad Miller
2014-12-28 15:36:41 -05:00
parent f3484686c9
commit 32f3bea465
2 changed files with 57 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
#include "WPILib.h"
/**
* Uses AxisCamera class 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 AxisCameraSample : public SampleRobot
{
IMAQdxSession session;
Image *frame;
IMAQdxError imaqError;
AxisCamera *camera;
public:
void RobotInit() override {
// create an image
frame = imaqCreateImage(IMAQ_IMAGE_RGB, 0);
// open the camera at the IP address assigned. This is the IP address that the camera
// can be accessed through the web interface.
camera = new AxisCamera("10.1.91.103");
}
void OperatorControl() override {
// 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()) {
camera->GetImage(frame);
imaqDrawShapeOnImage(frame, frame, { 10, 10, 100, 100 }, DrawMode::IMAQ_DRAW_VALUE, ShapeMode::IMAQ_SHAPE_OVAL, 0.0f);
CameraServer::GetInstance()->SetImage(frame);
Wait(0.05);
}
}
};
START_ROBOT_CLASS(AxisCameraSample);

View File

@@ -316,6 +316,26 @@
</files>
</example>
<example>
<name>Axis Camera Sample</name>
<description>An example program that acquires images from an Axis network 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. This demonstrates the use of the
AxisCamera class.
</description>
<tags>
<tag>Vision</tag>
<tag>Complete List</tag>
</tags>
<packages>
<package>src</package>
</packages>
<files>
<file source="examples/AxisCameraSample/src/Robot.cpp"
destination="src/Robot.cpp"></file>
</files>
</example>
<example>
<name>GearsBot</name>