Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   TrackTwoColors execution time (http://www.chiefdelphi.com/forums/showthread.php?t=73447)

Kruuzr 16-02-2009 13:12

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.

CardcaptorRLH85 16-02-2009 17:32

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.

Kruuzr 17-02-2009 00:05

Re: TrackTwoColors execution time
 
Quote:

Originally Posted by CardcaptorRLH85 (Post 822298)
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.

CardcaptorRLH85 17-02-2009 14:43

Re: TrackTwoColors execution time
 
Quote:

Originally Posted by Kruuzr (Post 822629)
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....


All times are GMT -5. The time now is 18:17.

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