![]() |
Goal Finder 2011 Documentation
Hey guys,
I wanted to quickly ask about this documentation posted here: http://firstforge.wpi.edu/sf/go/doc1209?nav=1 This is some sample code written to track the retro reflective tape on the scoring pegs. This code is written in Java and I was wondering whether anyone knows where I can find something similar for C++. We mainly want to use the camera to align with the pegs so we can score in autonomous. Thanks for all your help. |
Re: Goal Finder 2011 Documentation
Quote:
#include "WPILib.h" class RobotDemo : public SimpleRobot { RobotDrive *myRobot; Joystick *Gamepad; AxisCamera *camera; ColorImage *colorImage; ParticleAnalysisReport sparticles; DriverStation *ds; BinaryImage *binImage; public: RobotDemo(void) { myRobot = new RobotDrive(10, 9); Gamepad = new Joystick (1); ds = DriverStation::GetInstance(); GetWatchdog().SetExpiration(100); } void Autonomous(void) { GetWatchdog().SetEnabled(false); } void OperatorControl(void) { printf("Getting camera instance\n"); camera -> AxisCamera::GetInstance(); printf("Setting camera parameters\n"); camera -> WriteResolution(AxisCamera::kResolution_320x240); camera -> WriteCompression(20); camera -> WriteBrightness(35); GetWatchdog().SetEnabled(true); while (IsOperatorControl()) { GetWatchdog().Feed(); float rightDrive = Gamepad -> GetRawAxis (4); float leftDrive = Gamepad -> GetRawAxis (2); myRobot -> TankDrive (leftDrive, rightDrive); if (camera->IsFreshImage()) { colorImage = camera->GetImage(); // get the image from the camera binImage = colorImage->ThresholdHSL(242, 255, 36, 255, 25, 255); sparticles * BinaryImage::GetOrderedParticleAnalysisReports(); //System.out.println("Particles: " + sparticles->length); } }//end while } }; START_ROBOT_CLASS(RobotDemo); |
| All times are GMT -5. The time now is 17:43. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi