Open 9and3 opened 3 years ago
Hi,
We were able to run this code successfully using the latest SDK release, but when (experimentally) removing the using and Dispose, it then exhibits the behavior you're seeing, so a guess would be that somehow those frame objects are not actually being released on your end. The CLR maybe?
Hope this helps.
Thanks
Hello,
thank your for your answer. I did actually tried on different machines and different NET versions, we are all still reading the same error. Isn't there a workaround to the using/Dispose formula? Maybe a different way of formulate the while loop? Thanks
Unfortunately no. See Note here:
https://github.com/IntelRealSense/librealsense/tree/master/wrappers/csharp#hello-world
Thanks
i had the same issue i used threading to start streaming from the camera are u on WinForms or WPF ?
I believe I am in WPF. What would be the difference @Dalinaffeti I am interested? So the whole streaming loop would be done in a parallel thread? I will try out this, thanks!
Same here :(
I'm having the same issue. I tried running the rs_depth.c application and that also is throwing a timeout error. I don't think this is a C# problem but related to the underlying native code.
I agree. Personally I went back to the C++ API and did my own C# wrap just to call the functions I strictly needed for my applications. Didn't have a problem with that with buffers or anything else.
I had the same issue when I ran the camera on raspberry pi 4b, sometimes it doesnt freeze but sometimes it freeze. I dont surely know how to fix it and what causing the freeze
I had the same issue when I ran the camera on raspberry pi 4b, sometimes it doesnt freeze but sometimes it freeze. I dont surely know how to fix it and what causing the freeze↳
same problem :(
I have the same problem when I ran the t265 camera on my raspberry pi 4b.
You must dispose all frame(set)s associated with the pipeline before getting new one (unless you use the .Keep()
).
GC is an expensive process, hence the wrapper insists on disposal as soon as it is not used directly.
for example, instead of just:
// This will cause blocking for the next call because the wrapper expect to reuse the same object
// You need to dispose each of them
using var frm = align.Process(p.WaitForFrames()).AsFrameSet();
you have to do this (for current scope):
using var f1 = p.WaitForFrames();
using var f2 = align.Process(f1);
using var frm = f2.AsFrameSet();
or (for a more global scope):
CamFrameSet = p.WaitForFrames();
Aligned = align.Process(CamFrameSet).DisposeWith(CamFrameSet).AsFrameSet().DisposeWith(CamFrameSet);
so if the source frame gets disposed, the derivatives gets disposed. Unless you choose to use .Keep()
.
in @9and3's case, you must dispose this object:
f.As<PoseFrame>()
which will be:
// Cast the frame to pose_frame and get its data
var pose_data = f.As<PoseFrame>().DisposeWith(f).PoseData;
or you have to remove it from the pipeline's framepool
// Cast the frame to pose_frame and get its data
var tmp = f.As<PoseFrame>();
// put the frame out of the reuse cycle for the pipeline
tmp.Keep();
var pose_data = tmp.PoseData;
after this point, you're dependent on GC to dispose of tmp
once it goes out of scope, which is expensive and not reliable which may cause memory leak and performance degradation.
Issue Description
Hello! I am trying to retrieve pose data from the T265 tracking camera with C# wrappers. The pose is streamed for a while and than I got this error:
Unhandled Exception: System.Exception: Frame didn't arrive within 5000 ---> System.Runtime.InteropServices.ExternalException: rs2_pipeline_wait_for_frames(pipe:00000232D8DF2340) --- End of inner exception stack trace --- at Intel.RealSense.ErrorMarshaler.MarshalNativeToManaged(IntPtr pNativeData) at System.StubHelpers.MngdRefCustomMarshaler.ConvertContentsToManaged(IntPtr pMarshalState, Object& pManagedHome, IntPtr pNativeHome) at Intel.RealSense.NativeMethods.rs2_pipeline_wait_for_frames(IntPtr pipe, UInt32 timeout_ms, Object& error) at Intel.RealSense.Pipeline.WaitForFrames(UInt32 timeout_ms)
And here's my code:
I just would like to say that I tried the same code to run the tracking on C++, the same computer, and port USB and it runs perfectly.
Any idea? Thanks in advance!