Random errors getting frames
Hi,
I'm using D415 camera with firmware 5.14.0.0 and SDK 2.53.1.
Sometimes I'm not able to get frames and I get the exception Frame didn't arrive in XX ms timeout. I have observed that when this happens the StartStreaming command don't turn on the laser ligths in the camera.
I'm getting this error on both USB and Ethernet communications.
With regards,
-
Hi Juan Diezyanguas Would it be possible to paste your program code into a comment below please?
-
Hi,
Here are some of the important parts of the code implied in init camera and streaming.
The code is working fine, but the error sometimes is apearing and I didn't found some pattern or something like that.
protected void Initialize()
{
var sensors = _irsDevice.QuerySensors();
_irsCameraRgbSensor = sensors[1];
_irsCameraDepthSensor = sensors[0];
var colorProfile = _irsCameraRgbSensor.StreamProfiles
.Where(p => p.Stream == Stream.Color)
.Where(p => p.Framerate == 30)
.Select(p => p.As<VideoStreamProfile>())
.Where(p => p.Width == 640 && p.Height == 480)
.First();
var depthProfile = _irsCameraDepthSensor.StreamProfiles
.Where(p => p.Stream == Stream.Depth)
.Where(p => p.Framerate == 30)
.Select(p => p.As<VideoStreamProfile>())
.Where(p => p.Width == 640 && p.Height == 480)
.First();
_irsCameraCfg = new Config();
_irsCameraCfg.EnableStream(Stream.Depth, depthProfile.Width, depthProfile.Height, depthProfile.Format, depthProfile.Framerate);
_irsCameraCfg.EnableStream(Stream.Color, colorProfile.Width, colorProfile.Height, colorProfile.Format, colorProfile.Framerate);
}
public void StartStreaming()
{
if (!_isDeviceConnected || _isStreaming)
return;
_irsPipeline = new Pipeline(_irsContext);
_irsPipelineProfile = _irsPipeline.Start(_irsCameraCfg);
_isStreaming = true;
}
public RealSenseRequestFramesDto GetFrame()
{
try
{
ResetUnusedStreamingTimer();
if (!_isStreaming)
return new RealSenseRequestFramesDto(RealSenseException.NotStreamingException);
using (var frames = _irsPipeline.WaitForFrames(2000)) // Before 2000
{
var colorFrame = frames.ColorFrame.DisposeWith(frames);
var depthFrame = frames.DepthFrame.DisposeWith(frames);
var colorizedDepth = _colorizer.Process<VideoFrame>(depthFrame).DisposeWith(frames);
var colorFrameDto = new FrameDto(FrameType.RgbFrame, colorFrame);
var depthFrameDto = new FrameDto(FrameType.DepthFrame, colorizedDepth);
return new RealSenseRequestFramesDto(colorFrameDto, depthFrameDto);
}
}
catch (Exception ex)
{
return new RealSenseRequestFramesDto(new RealSenseException(RealSenseErrorType.RealSenseApiError, ex));
}
} -
As you are using a public void(), it looks as though it is a C# script. Is that correct, please?
If you are then I see that you are using a Using block to release frames so that the pipeline does not become jammed up and new frames are unable to arrive.
Does it make a difference if you remove 2000 from the brackets of WaitForFrames()
-
Hi,
This is part of a class that I'm using to manage RealSense camera, that's why the StartStreaming method is public.
You mean removing the timeout of WaitForFrames()? I can try it , but I'm not sure if it will work or the code will be blocked in this line.
I think that maybe the error is not on WaitForFrames(). I have noticed that when it happens the StartStreaming is not working. Usually when StartStreaming is called the camera laser is switched on, but when this error happens it seem that the camera is not switched because the laser is not switched on.
With regards,
-
You said in your opening comment that the error happens sometimes (suggesting that it does not happen every time). Does the program work the first time that you run it after the computer has booted? In a small number of cases, a RealSense program will work correctly on its first run but not on a second run or any subsequent runs afterwards until the computer has been rebooted.
You could eliminate the possibility that there is an issue with the _irsCameraCfg instructions by removing _irsCameraCfg from the pipe start line's brackets so that the program ignores the _irsCameraCfg stream configuration and applies the default stream settings instead.
-
Yes, that's true, the error is not always there. I didn't identified a pattern, sometimes it is solved by restarting the application and sometimes restarting the camera (unplug USB and plug USB again).
I think that the error occurs when I start streaming and stop streaming in subsequent operations multiple times.
Do you see something wrong in the pipeline configuration?
With regards,
-
There is nothing wrong with using 640x480 and 30 FPS. That configuration works well under most circumstances.
Whilst your _irsCameraCfg lines work, the method used is an unusual way to define their values. The more common approach would be this:
_irsCameraCfg.EnableStream(Stream.Depth, 640, 480, Format.Z16, 30);
_irsCameraCfg.EnableStream(Stream.Color, 640, 480, Format.Rgb8, 30);Does reliability improve if you use those lines in your script instead?
-
Thanks for your reply.
I did it when I started with RealSense and didn't have so much idea of the SDK and debugging I saw that inside the sensor I found all the possible profiles to apply.
With your method I can start pipeline withput quering sensor Stream profiles
Thanks for your reply! I will change it and see how it works.
Please sign in to leave a comment.
Comments
8 comments