Go to Post sometimes you have to put up with the rain to see the rainbow - Beth Sweet [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
  #16   Spotlight this post!  
Unread 26-01-2013, 23:11
bmbroom bmbroom is offline
Registered User
FRC #3103
 
Join Date: Jan 2013
Location: Houston
Posts: 2
bmbroom is an unknown quantity at this point
Re: Sample Vision Code, ComputeThreshold() exception

We are also having trouble getting an image using the sample vision code.

I am a complete newbie wrt the FRC competition, and doing my best to learn.

The camera.GetImage (image) function is not returning anything in image. The sample code does not initialize image, so it could point to garbage. The call to camera.GetImage (image) passes image by value so I don't see how it could change image and in our tests it doesn't appear to. Since it initially contains a garbage pointer, this might explain some of the errors people send when the code attempts to dereference the pointer.

I've tried to find/guess a way to initialize the pointer without success. The sample code doesn't show any way to initialize it, so it's very puzzling to me how it could work. The function documentation is not very information, and all the examples/help talks about what to do once you've obtained an image.

Any basic help would be appreciated.
Reply With Quote
  #17   Spotlight this post!  
Unread 27-01-2013, 01:21
Pulverator's Avatar
Pulverator Pulverator is offline
Registered User
FRC #1551 (The Grapes of Wrath)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Naples
Posts: 8
Pulverator is an unknown quantity at this point
Re: Sample Vision Code, ComputeThreshold() exception

Quote:
Originally Posted by bmbroom View Post
The call to camera.GetImage (image) passes image by value so I don't see how it could change image and in our tests it doesn't appear to. Since it initially contains a garbage pointer, this might explain some of the errors people send when the code attempts to dereference the pointer.
I'm pretty sure it passes by pointer as this is the declaration in AxisCamera.h.
Code:
int GetImage(ColorImage *image);
It's my understanding that calling this method will set the passed pointer which in this case is "image." I agree with you that after calling this function, image does not appear to be valid.
Reply With Quote
  #18   Spotlight this post!  
Unread 27-01-2013, 02:09
bmbroom bmbroom is offline
Registered User
FRC #3103
 
Join Date: Jan 2013
Location: Houston
Posts: 2
bmbroom is an unknown quantity at this point
Re: Sample Vision Code, ComputeThreshold() exception

Quote:
Originally Posted by Pulverator View Post
I'm pretty sure it passes by pointer as this is the declaration in AxisCamera.h.
Code:
int GetImage(ColorImage *image);
It's my understanding that calling this method will set the passed pointer which in this case is "image."
My understanding is that it can change whatever image is pointing to, but to change image itself it needs a pointer/reference to the image variable itself.

Trying storing a known value in image before calling GetImage and then comparing that to the value on return.
Code:
ColorImage *image = NULL;
camera.GetImage (image);
SmartDashboard::PutString ("image changed", image == NULL ? "no" : "yes");
(Apologies in advance if I messed up the syntax/function calls. This is from memory. I hope you get the general idea.)

P.S. Don't keep processing if image==NULL, the pointer dereference will cause an error.

In our tests, the value in image never changed.

I looked for other ways to initialize image but couldn't find anything.

One thing I'll try when I next get a chance on the robot will be to put the access to the test image back in and see if that will work as a workable initializer.
Reply With Quote
  #19   Spotlight this post!  
Unread 18-09-2013, 10:06
Rabell Rabell is offline
Registered User
FRC #3802 (RoboPOP)
Team Role: Mentor
 
Join Date: Sep 2013
Rookie Year: 2011
Location: Plano Texas
Posts: 2
Rabell is an unknown quantity at this point
Re: Sample Vision Code, ComputeThreshold() exception

I have begun to try C++ and ran the 2013 vision example, but seem to be having a problem similar to what is described here.

I have not yet attempted to debug it much other than to know that the driver station crashes out starting with the following line when I'm trying to use the camera rather than trying the files.

BinaryImage *thresholdImage = image->ThresholdHSV(threshold);

I was hoping that someone would have posted a solution, but it's not clear from the description here that there is one. However, I presume that someone figured this out before competition.

I have loaded the last update available and am using the M1011 camera.

If someone identified a clear solution would you please post it.

thanks.
Reply With Quote
  #20   Spotlight this post!  
Unread 18-09-2013, 11:28
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Re: Sample Vision Code, ComputeThreshold() exception

Code:
BinaryImage *thresholdImage = image->ThresholdHSV(threshold);
It looks like you're trying to create a pointer and store something in what it points to at the same time. That will write over an undefined area in memory. Or maybe you're just setting it to something that won't fit in a pointer, and thus overwriting memory that way?

Don't do that.

Instead, declare the pointer, then allocate memory and set the pointer to point to the newly allocated memory. Only after that's done can you dereference the pointer. Alternatively, you might want to create thresholdImage as a BinaryImage instead of a pointer to one.
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:38.

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