Go to Post Robotics = my anti drug. - Queen_of_Mascot [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 08-02-2012, 20:17
Method's Avatar
Method Method is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Ca
Posts: 38
Method is an unknown quantity at this point
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);
Reply With Quote
  #2   Spotlight this post!  
Unread 08-02-2012, 20:44
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Camera bug

The vision targeting code is a lot more complicated than what you have here. Please refer to the VisionSample2012 code. If you downloaded update 3111 from here, you should have that example code.
http://firstforge.wpi.edu/sf/frs/do/...2_update_for_c

Also, a quick scan of your code showed that you are not printing the numbers correctly.
Code:
driverOut->PrintfLine(DriverStationLCD::kUser_Line1, "Z: %n", particles->size());//output num targets
driverOut->PrintfLine(DriverStationLCD::kUser_Line2, "sumtin %f", par.center_mass_y);
If I am guessing what you are trying to do correctly, it should be: (both fields are integers).
Code:
driverOut->PrintfLine(DriverStationLCD::kUser_Line1, "Z: %d", particles->size());//output num targets
driverOut->PrintfLine(DriverStationLCD::kUser_Line2, "sumtin %d", par.center_mass_y);
__________________
Reply With Quote
  #3   Spotlight this post!  
Unread 08-02-2012, 22:01
Method's Avatar
Method Method is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Ca
Posts: 38
Method is an unknown quantity at this point
Re: Camera bug

This example makes life 1000* easier. thanks for pointing the way
Reply With Quote
  #4   Spotlight this post!  
Unread 08-02-2012, 23:20
Method's Avatar
Method Method is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Ca
Posts: 38
Method is an unknown quantity at this point
Re: Camera bug

image = new RGBImage("/10ft2.jpg");

How do I get '/10ft2.jpg' from the camera instead?

camera.GetImage() <returns a HSL image. Can I convert this in C++ to RGB instead of by the vision assistant software?
Reply With Quote
  #5   Spotlight this post!  
Unread 09-02-2012, 00:45
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: Camera bug

AxisCamera::GetImage has three overloads. One takes a ColorImage* as parameter.
Code:
int AxisCamera::GetImage(ColorImage* image)
__________________
Reply With Quote
  #6   Spotlight this post!  
Unread 09-02-2012, 00:46
Method's Avatar
Method Method is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Ca
Posts: 38
Method is an unknown quantity at this point
Re: Camera bug

nvm got it!



ColorImage image(IMAQ_IMAGE_RGB);
camera.GetImage(&image);
BinaryImage *thresholdImage = image.ThresholdRGB(threshold);
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

driverOut->PrintfLine(DriverStationLCD::kUser_Line2, "Target Select, numTargets: %n", (int)particles->size());
driverOut->UpdateLCD();


delete particles;
delete filteredImage;
delete convexHullImage;
delete bigObjectsImage;
delete thresholdImage;
delete &image;
Reply With Quote
  #7   Spotlight this post!  
Unread 09-02-2012, 04:22
Method's Avatar
Method Method is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Ca
Posts: 38
Method is an unknown quantity at this point
Re: Camera bug

Okay-> I modified my code to match theirs. There are probably still a few bugs so I'd appreciate someone's glancing at it. The functions I'm interested in right now are all above autonomous and operator control. sorry it's a little messy right now; I'll put everything in classes and such later
Attached Files
File Type: cpp Doc8.cpp (14.0 KB, 17 views)
Reply With Quote
  #8   Spotlight this post!  
Unread 09-02-2012, 22:30
Method's Avatar
Method Method is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Ca
Posts: 38
Method is an unknown quantity at this point
Re: Camera bug

tested today and messed with it more. everything works now. thanks
Reply With Quote
  #9   Spotlight this post!  
Unread 12-02-2012, 22:34
duane's Avatar
duane duane is offline
Registered User
FRC #0701 (RoboVikes)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2003
Location: Vacaville
Posts: 90
duane is an unknown quantity at this point
Send a message via AIM to duane
Re: Camera bug

When ever we do this (call GetImage()) the resulting image has 0 height and width. It seems like we are not getting back an image.

We are at somewhat of a loss to work out what we're doing wrong.

Pointers or suggestions for debugging would be great.

...Duane
__________________
Duane Murphy
Mentor - Software
Vanden Vikings FIRST Team 701
http://www.vandenrobotics.com
Reply With Quote
  #10   Spotlight this post!  
Unread 14-02-2012, 02:05
bob.wolff68's Avatar
bob.wolff68 bob.wolff68 is offline
Da' Mentor Man
FRC #1967
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2007
Location: United States
Posts: 157
bob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nicebob.wolff68 is just really nice
Re: Camera bug

I've seen this happen if the camera isn't initialized -- but if you're doing the GetImage() repeatedly during a loop, then it's unlikely that.

If you haven't set the Brightness, that could do it -- so be sure to do camera.SetBrightness(40) as well.

Post a snip of the code if those hints don't get you anywhere.

:-)

bob
__________________
~~~~~~~~~~~~~~~~~~~
Bob Wolff - Software from the old-school
Mentor / C / C++ guy
Team 1967 - The Janksters - San Jose, CA
Reply With Quote
  #11   Spotlight this post!  
Unread 14-02-2012, 20:58
Method's Avatar
Method Method is offline
Registered User
no team
 
Join Date: Jan 2012
Rookie Year: 2011
Location: Ca
Posts: 38
Method is an unknown quantity at this point
Re: Camera bug

I got that working on and off but then tried to use the NI Vision Assistant to make better tracking code.

I eliminated some issues and incorporated it with robot code but still am having some troubles: there are a few errors and I'm not sure how to get the values I'm interested in.. though I am more secure about figuring the later out.

the errors in the C file seem to be related (there are five)
help?

The three files are rather long so I attached them.

thanks! : |)
Attached Files
File Type: zip camera tracking files.zip (5.6 KB, 9 views)
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 13:06.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi