Commit f5792482 authored by Thiago C. Santini's avatar Thiago C. Santini

Drops first second worth of frames

Some of the initial timestamps incoming from the camera driver have a
weird timestamp (e.g., negative).
We now drop the first second worth of frames and consider from that on
that the driver is stable.

At that time, we synchronize the recording started time to correspond to
the driver timestamp 0 as well as the global timer to correspond to the
current timestamp.
parent 3a16d69d
......@@ -185,6 +185,8 @@ ImageAcquisition::ImageAcquisition(QObject *parent) : QObject(parent),
if (master) {
qDebug() << "Master is " << camToStr(*master);
dropCountWhenStarting = master->format.fps; // drop first second worth of frames
// support frame callback does not work properly so we test the callback ourselves
// if( videoManControl.supportFrameCallback(master->id) )
//videoManControl.setFrameCallback(master->id, &ImageAcquisition::frameCallback, this);
......@@ -231,11 +233,22 @@ void ImageAcquisition::frameCallback(char *pixelBuffer, size_t input, double tim
void ImageAcquisition::frameCallbackInternal(char *pixelBuffer, size_t input, double timestamp)
{
if (!ready) {
recordingStarted = GetTickCount64();
gTimer.setOffset(recordingStarted+1e3*timestamp);
static double initial;
if (!ready)
ready = true;
if ( dropCountWhenStarting == 0) {
recordingStarted = GetTickCount64() - 1e3*timestamp; // i.e., when the camera timestamp was 0
gTimer.setOffset(recordingStarted + 1e3*timestamp); // synchronize timer with current timestamp
initial = 1e3*timestamp;
}
if (dropCountWhenStarting >= 0) {
dropCountWhenStarting--;
videoManControl.releaseFrame( master->id );
return;
}
ready = true;
if (running && pixelBuffer != NULL) {
JournalEntry entry(recordingStarted+timestamp*1e3);
......
......@@ -56,6 +56,7 @@ public:
Mat latestSlaveFrame;
Camera *slave;
bool running;
int dropCountWhenStarting;
signals:
void imageAcquisitionDone(JournalEntry journalEntry);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment