Hi!
I was just wanting to check that this is working correctly and make it available if so
I have a problem where enabling code would bring robot code and comms down till i reboot
I made this by cutting huge sections out of my code, simplifying them(I was separating R G and B then comparing particles[in separate files]), then putting them in the vision example
#include "WPILib.h"
#include "Vision/RGBImage.h"
#include "Vision/BinaryImage.h"
#define RL 200
#define RH 260
#define GL 140
#define GH 210
#define BL 90
#define BH 135
static AxisCamera &eyeOfSauron = AxisCamera::GetInstance("10.16.71.11");
DriverStationLCD* driverOut = DriverStationLCD::GetInstance();
//for smart dashboard
class VisionSample2012 : public SimpleRobot
{
DriverStationLCD* driverOut;
Joystick pilot;
public:
VisionSample2012(void):
pilot(1)
{
GetWatchdog().Kill();
driverOut = DriverStationLCD::GetInstance();
//eyeOfSauron.WriteBrightness(30);
//eyeOfSauron.WriteWhiteBalance(AxisCamera::kWhiteBalance_Hold);
eyeOfSauron.WriteResolution(AxisCamera::kResolution_320x240);
//eyeOfSauron.WriteColorLevel(100);
//eyeOfSauron.WriteCompression(30);
//lower easier on CRIO and harder on cam
eyeOfSauron.WriteMaxFPS(5);
}
void Autonomous(void)
{
GetWatchdog().Kill();
while (IsAutonomous() && IsEnabled())
{
GetWatchdog().Kill();
CamAnOut();
}
}
void OperatorControl(void)
{
GetWatchdog().Kill();
while (IsOperatorControl())
{
GetWatchdog().Kill();
CamAnOut();
}
}
void CamAnOut (void)
{
Threshold threshold(RH, RL, GH, GL, BH, BL);
ParticleFilterCriteria2 criteria] = {
{IMAQ_MT_BOUNDING_RECT_WIDTH, 10, 200, false, false},
{IMAQ_MT_BOUNDING_RECT_HEIGHT, 10, 200, false, false}};
// false Set this element to TRUE to take calibrated measurements.
// fales Set this element to TRUE to indicate that a match occurs when the measurement is outside the criteria range
// ColorImage *image;
// image = new RGBImage("/10ft2.jpg"); // get the sample image from the cRIO flash
ColorImage image(IMAQ_IMAGE_RGB);
//make image
eyeOfSauron.GetImage(&image);
//store camera feed to image
BinaryImage *thresholdImage = image.ThresholdRGB(threshold);
//pixel range
BinaryImage *bigObjectsImage = thresholdImage->RemoveSmallObjects(false, 2);
// remove small objects (noise)
BinaryImage *convexHullImage = bigObjectsImage->ConvexHull(false);
// fill in partial and full rectangles
BinaryImage *filteredImage = convexHullImage->ParticleFilter(criteria, 2);
// find the rectangles
vector<ParticleAnalysisReport> *particles = filteredImage->GetOrderedParticleAnalysisReports();
// get the results
//LCD output
if (IsAutonomous())
driverOut->Printf(DriverStationLCD::kUser_Line1, 1, "Autonomous");
else if (IsOperatorControl())
driverOut->Printf(DriverStationLCD::kUser_Line1, 1, "Operat or");
//too many, or too few targets? If not, how many?
if (particles->size() == 0)
driverOut->Printf(DriverStationLCD::kUser_Line2, 1, "loosen filter");
else if (particles->size() > 4)
driverOut->Printf(DriverStationLCD::kUser_Line2, 1, "tighten filter");
else
{ //TRY I
driverOut->Printf(DriverStationLCD::kUser_Line2, 1, "Number of targets: %d", particles->size());
}
//update the LCD on the DS
driverOut->UpdateLCD( );
//delete reports;
delete filteredImage;
delete convexHullImage;
delete bigObjectsImage;
delete thresholdImage;
delete ℑ
}
};
START_ROBOT_CLASS(VisionSample2012);