CameraRGBD: Removed framerate warning when set to 0 (inf)

This commit is contained in:
matlabbe
2015-05-06 17:38:14 -04:00
parent 1f8fc91f46
commit 3642e2fbf1
+5 -6
View File
@@ -94,10 +94,9 @@ void CameraRGBD::takeImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & f
{ {
bool warnFrameRateTooHigh = false; bool warnFrameRateTooHigh = false;
float actualFrameRate = 0; float actualFrameRate = 0;
float imageRate = _imageRate==0.0f?20.0f:_imageRate; // limit to 20Hz if infinity if(_imageRate>0)
if(imageRate>0)
{ {
int sleepTime = (1000.0f/imageRate - 1000.0f*_frameRateTimer->getElapsedTime()); int sleepTime = (1000.0f/_imageRate - 1000.0f*_frameRateTimer->getElapsedTime());
if(sleepTime > 2) if(sleepTime > 2)
{ {
uSleep(sleepTime-2); uSleep(sleepTime-2);
@@ -109,14 +108,14 @@ void CameraRGBD::takeImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & f
} }
// Add precision at the cost of a small overhead // Add precision at the cost of a small overhead
while(_frameRateTimer->getElapsedTime() < 1.0/double(imageRate)-0.000001) while(_frameRateTimer->getElapsedTime() < 1.0/double(_imageRate)-0.000001)
{ {
// //
} }
double slept = _frameRateTimer->getElapsedTime(); double slept = _frameRateTimer->getElapsedTime();
_frameRateTimer->start(); _frameRateTimer->start();
UDEBUG("slept=%fs vs target=%fs", slept, 1.0/double(imageRate)); UDEBUG("slept=%fs vs target=%fs", slept, 1.0/double(_imageRate));
} }
UTimer timer; UTimer timer;
@@ -143,7 +142,7 @@ void CameraRGBD::takeImage(cv::Mat & rgb, cv::Mat & depth, float & fx, float & f
if(warnFrameRateTooHigh) if(warnFrameRateTooHigh)
{ {
UWARN("Camera: Cannot reach target image rate %f Hz, current rate is %f Hz and capture time = %f s.", UWARN("Camera: Cannot reach target image rate %f Hz, current rate is %f Hz and capture time = %f s.",
imageRate, actualFrameRate, timer.ticks()); _imageRate, actualFrameRate, timer.ticks());
} }
else else
{ {