<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Quote:samontab wrote: in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046471#M48231</link>
    <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;samontab wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;sm.Init() should be paired with sm.Release() instead of sm.Close()&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px; line-height: 17.7382px;"&gt;Thank you very much for your help.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;But, in C#， i did not find sm.Release(), while there is sm.Releaseframe(). But i do not think they are same.&lt;/P&gt;

&lt;P&gt;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?&lt;/P&gt;

&lt;P&gt;{ My poor English may be more difficult to understanding than algorithm...LOL &amp;nbsp;}&lt;/P&gt;</description>
    <pubDate>Fri, 25 Sep 2015 12:29:56 GMT</pubDate>
    <dc:creator>Xin_X_2</dc:creator>
    <dc:date>2015-09-25T12:29:56Z</dc:date>
    <item>
      <title>sm.close() does not close successfully</title>
      <link>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046469#M48229</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;Hi,guys. It is me again &amp;gt;&amp;lt;&lt;/P&gt;

&lt;P&gt;Here is the SDK example.&lt;/P&gt;

&lt;PRE class="brush:csharp;"&gt;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();
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;And, I know &amp;nbsp;&lt;SPAN style="font-family: Consolas, 'Lucida Console', Menlo, Monaco, 'DejaVu Sans Mono', monospace, sans-serif; font-size: 13.008px; line-height: 17.7382px;"&gt;sm.StreamFrames(true); &amp;nbsp;will open a new thread to work. &lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: Consolas, 'Lucida Console', Menlo, Monaco, 'DejaVu Sans Mono', monospace, sans-serif; font-size: 13.008px; line-height: 17.7382px;"&gt;But, what does sm.close() mean? Just to Close&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-family: Consolas, 'Lucida Console', Menlo, Monaco, 'DejaVu Sans Mono', monospace, sans-serif; font-size: 13.008px; line-height: 17.7382px;"&gt;sm.StreamFrames?&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG style="font-size: 1em; line-height: 1.5;"&gt;&lt;SPAN style="font-family: Consolas, 'Lucida Console', Menlo, Monaco, 'DejaVu Sans Mono', monospace, sans-serif; font-size: 13.008px; line-height: 17.7382px;"&gt;in other word, that is to close this created thread?&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;SPAN style="font-family: Consolas, 'Lucida Console', Menlo, Monaco, 'DejaVu Sans Mono', monospace, sans-serif; font-size: 13.008px; line-height: 17.7382px;"&gt;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...&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Consolas, Lucida Console, Menlo, Monaco, DejaVu Sans Mono, monospace, sans-serif"&gt;&lt;SPAN style="line-height: 17.7382px;"&gt;So, why ?&amp;nbsp;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="Consolas, Lucida Console, Menlo, Monaco, DejaVu Sans Mono, monospace, sans-serif"&gt;&lt;SPAN style="line-height: 17.7382px;"&gt;And how to use sm.close() correctly?&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;FONT face="Consolas, Lucida Console, Menlo, Monaco, DejaVu Sans Mono, monospace, sans-serif"&gt;&lt;SPAN style="line-height: 17.7382px;"&gt;Thank you very much!&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-family: Consolas, 'Lucida Console', Menlo, Monaco, 'DejaVu Sans Mono', monospace, sans-serif; font-size: 13.008px; line-height: 17.7382px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 03:19:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046469#M48229</guid>
      <dc:creator>Xin_X_2</dc:creator>
      <dc:date>2015-09-25T03:19:38Z</dc:date>
    </item>
    <item>
      <title>sm.Init() should be paired</title>
      <link>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046470#M48230</link>
      <description>&lt;P&gt;sm.Init() should be paired with sm.Release() instead of sm.Close()&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 04:02:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046470#M48230</guid>
      <dc:creator>samontab</dc:creator>
      <dc:date>2015-09-25T04:02:47Z</dc:date>
    </item>
    <item>
      <title>Quote:samontab wrote:</title>
      <link>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046471#M48231</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;samontab wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;sm.Init() should be paired with sm.Release() instead of sm.Close()&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px; line-height: 17.7382px;"&gt;Thank you very much for your help.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;But, in C#， i did not find sm.Release(), while there is sm.Releaseframe(). But i do not think they are same.&lt;/P&gt;

&lt;P&gt;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?&lt;/P&gt;

&lt;P&gt;{ My poor English may be more difficult to understanding than algorithm...LOL &amp;nbsp;}&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 12:29:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046471#M48231</guid>
      <dc:creator>Xin_X_2</dc:creator>
      <dc:date>2015-09-25T12:29:56Z</dc:date>
    </item>
    <item>
      <title>In C++ this is how it works:</title>
      <link>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046472#M48232</link>
      <description>&lt;P&gt;In C++ this is how it works:&lt;/P&gt;

&lt;P&gt;You need to first create an instance of the session with PXCSenseManager::CreateInstance();&lt;/P&gt;

&lt;P&gt;The resources of this session need to be released with PXCSenseManager::Release();&lt;/P&gt;

&lt;P&gt;In between those calls, and after you call Init(), you can access the frames by pairing AcquireFrame/ReleaseFrame calls.&lt;/P&gt;

&lt;P&gt;If, instead of calling them you use StreamFrames(), then you need to call Close() to terminate that thread.&lt;/P&gt;

&lt;P&gt;Now, in C# everything should be the same, except that Release() is called &lt;SPAN class="f_CodeExample"&gt;&lt;STRONG&gt;Dispose()&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 13:51:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046472#M48232</guid>
      <dc:creator>samontab</dc:creator>
      <dc:date>2015-09-25T13:51:14Z</dc:date>
    </item>
    <item>
      <title>Quote:samontab wrote:</title>
      <link>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046473#M48233</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;samontab wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;In C++ this is how it works:&lt;/P&gt;

&lt;P&gt;You need to first create an instance of the session with PXCSenseManager::CreateInstance();&lt;/P&gt;

&lt;P&gt;The resources of this session need to be released with PXCSenseManager::Release();&lt;/P&gt;

&lt;P&gt;In between those calls, and after you call Init(), you can access the frames by pairing AcquireFrame/ReleaseFrame calls.&lt;/P&gt;

&lt;P&gt;If, instead of calling them you use StreamFrames(), then you need to call Close() to terminate that thread.&lt;/P&gt;

&lt;P&gt;Now, in C# everything should be the same, except that Release() is called &lt;STRONG&gt;Dispose()&lt;/STRONG&gt;;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Yes, i read the same &amp;nbsp;things from the SDK. And now i am sure that the function Close() is to kill/terminate the thread which is created by StreamFrames().&lt;/P&gt;

&lt;P&gt;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().&lt;/P&gt;

&lt;P&gt;However, &amp;nbsp;ALL the UI are frozen...&lt;/P&gt;

&lt;P&gt;My program is very like it&amp;nbsp;http://www.i-programmer.info/programming/hardware/8496-real-realsense-in-c-event-streams.html &amp;nbsp;&lt;/P&gt;

&lt;P&gt;Also in this article, the author said&amp;nbsp;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
	&lt;P style="margin-bottom: 5px; color: rgb(51, 51, 51); font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18.2px;"&gt;How to stop the streaming?&lt;/P&gt;

	&lt;P style="margin-bottom: 5px; color: rgb(51, 51, 51); font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18.2px;"&gt;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.&amp;nbsp;&lt;/P&gt;

	&lt;P style="margin-bottom: 5px; color: rgb(51, 51, 51); font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18.2px;"&gt;&lt;CODE&gt;private void Button_Click_1(object sender,&amp;nbsp;&lt;BR /&gt;
		&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; RoutedEventArgs e)&lt;BR /&gt;
		{&lt;BR /&gt;
		&amp;nbsp;sm.Close();&lt;BR /&gt;
		}&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P style="margin-bottom: 5px; color: rgb(51, 51, 51); font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18.2px;"&gt;&lt;CODE&gt;So i am very confused, as even i copy the same code, my UI is also frozen...&lt;/CODE&gt;&lt;/P&gt;

&lt;P style="margin-bottom: 5px; color: rgb(51, 51, 51); font-family: Helvetica, Arial, sans-serif; font-size: 14px; line-height: 18.2px;"&gt;&amp;nbsp;&lt;/P&gt;

&lt;P style="margin-bottom: 5px; color: rgb(51, 51, 51); font-size: 14px; line-height: 18.2px;"&gt;&lt;FONT face="Consolas, Lucida Console, Menlo, Monaco, DejaVu Sans Mono, monospace, sans-serif"&gt;Thank you so much for your value time and patience.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 14:15:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046473#M48233</guid>
      <dc:creator>Xin_X_2</dc:creator>
      <dc:date>2015-09-25T14:15:57Z</dc:date>
    </item>
    <item>
      <title>When you work with a GUI, you</title>
      <link>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046474#M48234</link>
      <description>&lt;P&gt;When you work with a GUI, you need to make sure that the main thread remains as responsive as possible.&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;

&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2015 14:54:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/sm-close-does-not-close-successfully/m-p/1046474#M48234</guid>
      <dc:creator>samontab</dc:creator>
      <dc:date>2015-09-25T14:54:16Z</dc:date>
    </item>
  </channel>
</rss>

