Go to Post I didn't know that Dean Kamen had 3 arms. - kevin.li.rit [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 16-02-2009, 13:12
Kruuzr Kruuzr is offline
Mentor - electrical, software
AKA: Steve Cote
FRC #1922 (Ozram)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Henniker, NH
Posts: 33
Kruuzr has a spectacular aura aboutKruuzr has a spectacular aura about
Re: TrackTwoColors execution time

Another aspect that will effect the CPU loading is how often you are calling the TrackTwoColors() routine. The number of images per second that are retrieved from the camera is set at the StartCameraTask() call. Once you have a new image and process it once, if you keep calling TrackTwoColors() you will not only chew up CPU time, but you will keep getting the same answer back (you're checking the same image). If the camera task is a lower priority than the main task (I don't know) then the constant vision processing in the main loop may be backlogging the camera task. Regardless, it's a whole lot of useless CPU hogging.

We made a 'newImageAvailable()' function, which uses the GetImage() function (which returns a timestamp) to determine when a new image is available. So we only have to do our version of the TrackTwoColors() call once per new image. With a 160x120 image size, we easily do 15 frames per second. We could maybe do more but haven't tried.

Steve C.
Reply With Quote
  #17   Spotlight this post!  
Unread 16-02-2009, 17:32
CardcaptorRLH85's Avatar
CardcaptorRLH85 CardcaptorRLH85 is offline
The master of the cards ^_^
AKA: Raa'Shaun H.
FRC #0322 (F.I.R.E. "Flint Inspires Real Engineers")
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Michigan, USA
Posts: 59
CardcaptorRLH85 is an unknown quantity at this point
Send a message via ICQ to CardcaptorRLH85 Send a message via AIM to CardcaptorRLH85 Send a message via MSN to CardcaptorRLH85 Send a message via Yahoo to CardcaptorRLH85
Re: TrackTwoColors execution time

Is there any way that we could see a sample of your newImageAvailable() function Kruuzr? I'm looking at the GetImage() function but I see it returning an int (1 for success and -1 for failure). Not the double timestamp.
__________________


Last edited by CardcaptorRLH85 : 16-02-2009 at 17:43.
Reply With Quote
  #18   Spotlight this post!  
Unread 17-02-2009, 00:05
Kruuzr Kruuzr is offline
Mentor - electrical, software
AKA: Steve Cote
FRC #1922 (Ozram)
Team Role: Engineer
 
Join Date: Feb 2006
Rookie Year: 2006
Location: Henniker, NH
Posts: 33
Kruuzr has a spectacular aura aboutKruuzr has a spectacular aura about
Re: TrackTwoColors execution time

Quote:
Originally Posted by CardcaptorRLH85 View Post
Is there any way that we could see a sample of your newImageAvailable() function Kruuzr? I'm looking at the GetImage() function but I see it returning an int (1 for success and -1 for failure). Not the double timestamp.
Sorry I didn't get back to you earlier. (Last build night already started).

I don't have the code in front of me, but I believe the two parameters for GetImage() are Image* and double*. It may get the image into your Image* param but it also puts the timestamp into your double. The code looks something like this:

Image* image; // created using frcCreateImage() somewhere else

bool newImageAvailable()
{
double timestamp;
static double lastTimestamp = 0.0;

GetImage( image, &timestamp );
if ( timestamp > lastTimestamp )
{
lastTimestamp = timestamp;
return true;
}

return false;
}

I may have missed something but I think that's it.

Steve C.
Reply With Quote
  #19   Spotlight this post!  
Unread 17-02-2009, 14:43
CardcaptorRLH85's Avatar
CardcaptorRLH85 CardcaptorRLH85 is offline
The master of the cards ^_^
AKA: Raa'Shaun H.
FRC #0322 (F.I.R.E. "Flint Inspires Real Engineers")
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Michigan, USA
Posts: 59
CardcaptorRLH85 is an unknown quantity at this point
Send a message via ICQ to CardcaptorRLH85 Send a message via AIM to CardcaptorRLH85 Send a message via MSN to CardcaptorRLH85 Send a message via Yahoo to CardcaptorRLH85
Re: TrackTwoColors execution time

Quote:
Originally Posted by Kruuzr View Post
Sorry I didn't get back to you earlier. (Last build night already started).

I don't have the code in front of me, but I believe the two parameters for GetImage() are Image* and double*. It may get the image into your Image* param but it also puts the timestamp into your double. The code looks something like this:

Image* image; // created using frcCreateImage() somewhere else

bool newImageAvailable()
{
double timestamp;
static double lastTimestamp = 0.0;

GetImage( image, &timestamp );
if ( timestamp > lastTimestamp )
{
lastTimestamp = timestamp;
return true;
}

return false;
}

I may have missed something but I think that's it.

Steve C.
Thank you for the code. I don't know why I didn't notice that GetImage() used the double pointer in that way. I guess that's what happens when you become sleep deprived at the end of a build season....
__________________

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Single button function execution RonStoppable102 Programming 2 05-01-2007 09:45
User Processor Execution Time Andrew Blair Programming 1 12-02-2006 21:52
Loop execution time for Autonomous code Transporter08 Programming 2 13-02-2005 16:17
How to measure execution time? And code size? gnormhurst Programming 17 17-02-2004 08:06
Actual execution time measurement Dan Technical Discussion 5 24-03-2003 11:36


All times are GMT -5. The time now is 12:34.

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