Permalink
Browse files

Made a few minor profiling and nanosleep changes.

  • Loading branch information...
chachi committed Feb 18, 2010
1 parent 99ae02c commit 3c36a92caea9f0bb8c4cf1cb9cc94a0ed3f3c7bd
Showing with 17 additions and 15 deletions.
  1. +2 −0 Man.cpp
  2. +11 −6 corpus/ALImageTranscriber.cpp
  3. +3 −6 vision/Threshold.cpp
  4. +1 −3 vision/Vision.cpp
View
@@ -173,7 +173,9 @@ Man::processFrame ()
PROF_EXIT(profiler.get(), P_GETIMAGE);
#ifdef USE_VISION
//if(camera_active)
+ PROF_ENTER(profiler, P_VISION);
vision->notifyImage(sensors->getImage());
+ PROF_EXIT(profiler, P_VISION);
//vision->notifyImage();
#endif
@@ -76,13 +76,18 @@ void ALImageTranscriber::run() {
<< " frame length: " << processTime <<endl;
//Don't sleep at all
} else{
- //cout << "Sleeping for " << VISION_FRAME_LENGTH_uS
- //-processTime << endl;
+ const long int microSleepTime = (VISION_FRAME_LENGTH_uS -
+ processTime);
+ const long int nanoSleepTime =
+ (microSleepTime %(1000 * 1000)) * 1000;
- //nanosleep(10000000);
- interval.tv_sec = 0;
- interval.tv_nsec = static_cast<long long int>((VISION_FRAME_LENGTH_uS
- -processTime) * 1000);
+ const long int secSleepTime = microSleepTime / (1000*1000);
+
+ // cout << "Sleeping for nano: " << nanoSleepTime <<
+ // " and sec:" << secSleepTime << endl;
+
+ interval.tv_sec = secSleepTime;
+ interval.tv_nsec = nanoSleepTime;
nanosleep(&interval, &remainder);
}
View
@@ -115,14 +115,14 @@ void Threshold::visionLoop() {
// This will form all lines and all corners. After this call, fieldLines
// will be able to supply information about them through getLines() and
// getCorners().
- PROF_ENTER(vision->profiler, P_OBJECT);
+ PROF_ENTER(vision->profiler, P_LINES);
vision->fieldLines->lineLoop();
+ PROF_EXIT(vision->profiler, P_LINES);
// do recognition
+ PROF_ENTER(vision->profiler, P_OBJECT);
objectRecognition();
PROF_EXIT(vision->profiler, P_OBJECT);
-
- PROF_ENTER(vision->profiler, P_LINES);
vision->fieldLines->afterObjectFragments();
// For now we don't set shooting information
if (vision->bgCrossbar->getWidth() > 0) {
@@ -133,9 +133,6 @@ void Threshold::visionLoop() {
}
// for now we also don't use open field information
//field->openDirection(horizon, pose.get());
- PROF_EXIT(vision->profiler, P_LINES);
-
-
#ifdef OFFLINE
if (visualHorizonDebug) {
View
@@ -114,7 +114,7 @@ void Vision::notifyImage(const byte* image) {
void Vision::notifyImage() {
// NORMAL VISION LOOP
- PROF_ENTER(profiler, P_VISION);
+
frameNumber++;
// counts the frameNumber
@@ -127,8 +127,6 @@ void Vision::notifyImage() {
// Perform image correction, thresholding, and object recognition
thresh->visionLoop();
-
- PROF_EXIT(profiler, P_VISION);
}
void Vision::setImage(const byte *image) {

0 comments on commit 3c36a92

Please sign in to comment.