|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Trouble with code for camera
Right now I am working some of the code form the 2010Vision Sample code. Here is what i have.
if (trigger = stick->GetTrigger()) { //if (trigger != lastTrigger) // if there's a fresh and we're at the previous target heading then // get a camera image and process it if (camera.IsFreshImage()) { // get the camera image HSLImage *image = camera.GetImage(); //HSLImage *image; //image = new HSLImage("/10ft2.jpg"); // get the sample image from the cRIO flash BinaryImage *thresholdImage = image->ThresholdHSL(threshold); // get just the red target pixels 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> *reports = filteredImage->GetOrderedParticleAnalysisReports(); // get the results int b = 0; for (unsigned i = 0; i < reports->size(); i++) { ParticleAnalysisReport *r = &(reports->at(i)); DS->DriverStationLCD: rintf(DriverStationLCD::kUser_ Line1,1,"Particle: %d center_mass: %d \n",r->center_mass_x);//DS->DriverStationLCD::UpdateLCD(); //printf("particle: %d center_mass_x: %d\n", i, r->center_mass_x); b = r->center_mass_x; } When I press the trigger to get an image I lose communication with the robot. After a minute or two it robots and I can enable and drive. I tested the orginal code with added printf statements to to get an understanding of how it works and I did not have this problem. Is something wrong with my code? |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|