|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Camera bug
z:
sumtin 0.0000000 Hi! Im trying to get my camera working. Above is my output (should be num targets followed by fraction of distance of the first target to center) I made this simple V of code to debug but no luck help plz #include "WPILib.h" #include "nivision.h" #include <stdlib.h> #define IO (DriverStation::GetInstance()->GetEnhancedIO()) static AxisCamera &camera = AxisCamera::GetInstance("10.16.71.11"); //output from cameras to driverstation (so we can see it) static ColorImage image(IMAQ_IMAGE_HSL); //create an image to buffer pics static DriverStationLCD* driverOut = DriverStationLCD::GetInstance(); BinaryImage* binImg; class RobotDemo : public SimpleRobot { Joystick stick; // only joystick public: RobotDemo(void): stick(1) // as they are declared above. { GetWatchdog().Kill(); binImg = image.ThresholdHSL(0, 250, 30, 200, 130, 270); //HSL values (MUST BE FOUND BY EXPERIMENT) camera.WriteMaxFPS(30); //FPS camera.WriteBrightness(30); // camera.WriteWhiteBalance(AxisCamera::kWhiteBalance _Hold); //white balance -- set manually via internet connection w/hold camera.WriteResolution(AxisCamera::kResolution_320 x240); //resolution camera.WriteColorLevel(100); //low color camera.WriteCompression(30); //lower easier on CRIO and harder on cam } void Autonomous(void) { GetWatchdog().Kill(); } void OperatorControl(void) { GetWatchdog().Kill(); while (IsOperatorControl()) { camera.GetImage(&image); vector<ParticleAnalysisReport>* particles = binImg->GetOrderedParticleAnalysisReports(); ParticleAnalysisReport& par = (*particles)[1]; driverOut->Clear(); if (stick.GetRawButton(1)) { driverOut->PrintfLine(DriverStationLCD::kUser_Line1, "Z: %n", particles->size());//output num targets driverOut->PrintfLine(DriverStationLCD::kUser_Line2, "sumtin %f", par.center_mass_y); //output fraction of anle to target 1 in center of screen } driverOut->UpdateLCD(); } } }; START_ROBOT_CLASS(RobotDemo); |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|