Skip to content

Commit

Permalink
Make image timestamps consistent (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
f00f authored and mischastik committed Dec 3, 2018
1 parent c388c1f commit 40089a0
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 31 deletions.
10 changes: 1 addition & 9 deletions BetaCameras/Kinect2/Kinect2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,6 @@ protected virtual FloatCameraImage CalcDistances()
img[y, x] = depthFrameData[idx] * distanceMap[y, depthWidthMinusOne - x] * 0.001f;
}
}

img.TimeStamp = timestampDepth;
}
return img;
}
Expand All @@ -745,9 +743,7 @@ protected virtual unsafe ColorCameraImage CalcColor()
bmp.UnlockBits(bData);
bmp.RotateFlip(RotateFlipType.RotateNoneFlipX); //Kinect images are flipped in x-direction

ColorCameraImage img = new ColorCameraImage(bmp);
img.TimeStamp = timestampColor;
return img;
return new ColorCameraImage(bmp);
}
}

Expand All @@ -766,8 +762,6 @@ protected virtual FloatCameraImage CalcAmplitudes()
img[y, x] = (float)this.irFrameData[idx];
}
}

img.TimeStamp = timestampIR;
}
return img;
}
Expand Down Expand Up @@ -870,8 +864,6 @@ private Point3fCameraImage Calc3DCoordinates()
img[y, x] = new Point3f(worldPoints[idx].X * -1, worldPoints[idx].Y * -1, worldPoints[idx].Z);
}
}

img.TimeStamp = timestampDepth;
}
return img;
}
Expand Down
7 changes: 1 addition & 6 deletions BetaCameras/RealSense2/RealSense2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2004,7 +2004,6 @@ unsafe private FloatCameraImage CalcZImage()
int width = _currentDepthFrame.Width;

FloatCameraImage depthData = new FloatCameraImage(width, height);
depthData.TimeStamp = _currentFrameTimestamp;
short* source = (short*)_currentDepthFrame.Data;

for (int y = 0; y < height; y++)
Expand Down Expand Up @@ -2033,7 +2032,6 @@ unsafe private FloatCameraImage CalcIRImage(VideoFrame frame)
int width = frame.Width;

FloatCameraImage IRData = new FloatCameraImage(width, height);
IRData.TimeStamp = _currentFrameTimestamp;
byte* source = (byte*)frame.Data;

for (int y = 0; y < height; y++)
Expand Down Expand Up @@ -2072,10 +2070,7 @@ unsafe private ColorCameraImage CalcColor()
}

bitmap.UnlockBits(bmpData);
ColorCameraImage image = new ColorCameraImage(bitmap);
image.TimeStamp = _currentFrameTimestamp;

return image;
return new ColorCameraImage(bitmap);
}

#endregion
Expand Down
2 changes: 0 additions & 2 deletions BetaCameras/Sick.TiM561/TiM561.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ private FloatCameraImage CalcDistance()
{
ChannelName = _channelName,
FrameNumber = _scanCounter,
TimeStamp = _timeStamp
};

for (int x = 0; x < _radii.Length; ++x)
Expand Down Expand Up @@ -323,7 +322,6 @@ private Point3fCameraImage CalcPoint3DImage()
{
ChannelName = _channelName,
FrameNumber = _scanCounter,
TimeStamp = _timeStamp
};

for (int x = 0; x < _radii.Length; ++x)
Expand Down
4 changes: 0 additions & 4 deletions BetaCameras/Sick.VisionaryT/VisionaryT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,6 @@ private FloatCameraImage CalcIntensity()
lock (_frontLock)
{
result = new FloatCameraImage(_frontFrameData.Width, _frontFrameData.Height);
result.TimeStamp = (long)_frontFrameData.TimeStamp;
int start = _frontFrameData.IntensityStartOffset;
for (int i = 0; i < _frontFrameData.Height; ++i)
{
Expand All @@ -353,7 +352,6 @@ private FloatCameraImage CalcDistance()
lock (_frontLock)
{
result = new FloatCameraImage(_frontFrameData.Width, _frontFrameData.Height);
result.TimeStamp = (long)_frontFrameData.TimeStamp;
int start = _frontFrameData.DistanceStartOffset;
for (int i = 0; i < _frontFrameData.Height; ++i)
{
Expand All @@ -379,7 +377,6 @@ private UShortCameraImage CalcRawConfidenceMap()
lock (_frontLock)
{
result = new UShortCameraImage(_frontFrameData.Width, _frontFrameData.Height);
result.TimeStamp = (long)_frontFrameData.TimeStamp;
int start = _frontFrameData.ConfidenceStartOffset;
for (int i = 0; i < _frontFrameData.Height; ++i)
{
Expand Down Expand Up @@ -428,7 +425,6 @@ private Point3fCameraImage Calc3D()
lock (_frontLock)
{
result = new Point3fCameraImage(_frontFrameData.Width, _frontFrameData.Height);
result.TimeStamp = (long)_frontFrameData.TimeStamp;

float cx = _frontFrameData.CX;
float cy = _frontFrameData.CY;
Expand Down
16 changes: 6 additions & 10 deletions MetriCam2/Camera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ private ParamDesc<long> TimeStampDesc
/// By default the TimeStamp is set to DateTime.UtcNow.Ticks at the beginning of <see cref="Update"/>.
/// Individual cameras may override this behaviour and e.g. use a timestamp delivered by the camera itself.
/// </remarks>
public long TimeStamp { get; protected set; }
public long TimeStamp { get; private set; }

#if !NETSTANDARD2_0
/// <summary>
Expand Down Expand Up @@ -1212,8 +1212,8 @@ public void Connect()
throw ExceptionBuilder.Build(typeof(InvalidOperationException), Name, "error_connectionFailed");
}

this.FrameNumber = -1;
this.TimeStamp = -1;
FrameNumber = -1;
TimeStamp = -1;

if (OnConnecting != null)
{
Expand Down Expand Up @@ -1318,9 +1318,8 @@ public void Update()
{
this.hasUpdateBeenCalled = true;
this.FrameNumber++;
this.TimeStamp = DateTime.UtcNow.Ticks;

UpdateImpl();
this.TimeStamp = DateTime.UtcNow.Ticks;
}
}

Expand Down Expand Up @@ -1587,12 +1586,9 @@ public CameraImage CalcChannel(string channelName)
{
if (img.FrameNumber < 1)
{
img.FrameNumber = this.FrameNumber;
}
if (img.TimeStamp < 1)
{
img.TimeStamp = this.TimeStamp;
img.FrameNumber = FrameNumber;
}
img.TimeStamp = TimeStamp;
if (string.IsNullOrWhiteSpace(img.ChannelName))
{
img.ChannelName = channelName;
Expand Down

0 comments on commit 40089a0

Please sign in to comment.