mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-03 10:00:23 +08:00
Camera: fixed freezing when changing online frame rate from non zero to zero
This commit is contained in:
@@ -68,9 +68,10 @@ SensorData Camera::takeImage(CameraInfo * info)
|
|||||||
{
|
{
|
||||||
bool warnFrameRateTooHigh = false;
|
bool warnFrameRateTooHigh = false;
|
||||||
float actualFrameRate = 0;
|
float actualFrameRate = 0;
|
||||||
if(_imageRate>0)
|
float imageRate = _imageRate;
|
||||||
|
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);
|
||||||
@@ -82,14 +83,14 @@ SensorData Camera::takeImage(CameraInfo * info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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;
|
||||||
@@ -98,7 +99,7 @@ SensorData Camera::takeImage(CameraInfo * info)
|
|||||||
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, captureTime);
|
imageRate, actualFrameRate, captureTime);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user