- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,guys. It is me again ><
Here is the SDK example.
pxcmStatus OnNewSample(int mid, PXCMCapture.Sample sample) { // return NO ERROR to continue, // or any ERROR to exit the loop return pxcmStatus.PXCM_STATUS_NO_ERROR; } ... // Initialize my event handler PXCMSenseManager::Handler handler= new PXCMSenseManager.Handler(); handler.onNewSample=OnNewSample; // Stream depth samples sm.Init(handler); sm.StreamFrames(true); sm.Close();
And, I know sm.StreamFrames(true); will open a new thread to work.
But, what does sm.close() mean? Just to Close sm.StreamFrames? in other word, that is to close this created thread?
But in my simple WPF example, i add a new button to do sm.close(), the result is that the program crashed, and UI "frozen", i even cant close the program...
So, why ?
And how to use sm.close() correctly?
Thank you very much!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
sm.Init() should be paired with sm.Release() instead of sm.Close()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
samontab wrote:
sm.Init() should be paired with sm.Release() instead of sm.Close()
Thank you very much for your help.
But, in C#, i did not find sm.Release(), while there is sm.Releaseframe(). But i do not think they are same.
By the way, how do you close the thread? Or if you use callback way to get the sample from camera, how do you stop camera?
{ My poor English may be more difficult to understanding than algorithm...LOL }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In C++ this is how it works:
You need to first create an instance of the session with PXCSenseManager::CreateInstance();
The resources of this session need to be released with PXCSenseManager::Release();
In between those calls, and after you call Init(), you can access the frames by pairing AcquireFrame/ReleaseFrame calls.
If, instead of calling them you use StreamFrames(), then you need to call Close() to terminate that thread.
Now, in C# everything should be the same, except that Release() is called Dispose();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
samontab wrote:
In C++ this is how it works:
You need to first create an instance of the session with PXCSenseManager::CreateInstance();
The resources of this session need to be released with PXCSenseManager::Release();
In between those calls, and after you call Init(), you can access the frames by pairing AcquireFrame/ReleaseFrame calls.
If, instead of calling them you use StreamFrames(), then you need to call Close() to terminate that thread.
Now, in C# everything should be the same, except that Release() is called Dispose();
Yes, i read the same things from the SDK. And now i am sure that the function Close() is to kill/terminate the thread which is created by StreamFrames().
Just in my simple demo, I use one button to start the camera, it works and gets the sample from the camera; therefore i want to stop this camera by adding a new button Button2. When clicking Button2, it just run the sm.Close().
However, ALL the UI are frozen...
My program is very like it http://www.i-programmer.info/programming/hardware/8496-real-realsense-in-c-event-streams.html
Also in this article, the author said
How to stop the streaming?
Simple just add another button and call the SenseManager's Close method. To make this work we need to keep a reference to the SenseManager.
private void Button_Click_1(object sender,
RoutedEventArgs e)
{
sm.Close();
}
So i am very confused, as even i copy the same code, my UI is also frozen...
Thank you so much for your value time and patience.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When you work with a GUI, you need to make sure that the main thread remains as responsive as possible.
So, when you click the button, you could for example set a variable in another thread that eventually will close the camera. It is a bad idea to communicate directly with the camera from a GUI thread. That's probably why you see that problem.
I recommend you to read more about GUI programming. You can also start with a command line program to make it easier, and then build a GUI on top of your core program. It's always good to have an independent GUI anyway.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page