Items with no label
3335 討論

visual studio 2015 display SR300 colorstrem then memory overload

ewu12
新手
1,793 檢視

Hi, Sir

I'm beginner.

I got the color-stream by SR300 , then the image do Bi-level image and algorithm.

when i display the image about 5 min ,the error message show out "memory overload".

Could you give me some suggestion about program method ?

thanks.

edison.

.

1 解決方案
jb455
傑出貢獻者 II
387 檢視

Make sure you're calling https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?releaseframe_pxcsensemanager.html ReleaseFrame after QuerySample, https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?dispose_pxcmbase.html Dispose after any CreateX methods (eg, CreateProjection, CreateColorImageMappedToDepth etc - not immediately after, but when you're finished with the result for this frame), and https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?releaseaccess_pxcimage.html ReleaseAccess after AcquireAccess to avoid memory building up. If you're just doing simple streaming, your code should look something like this:

PXCMCapture.Sample photo = pSenseManager.QuerySample();

PXCMImage image = photo.color;

pSenseManager.ReleaseFrame();

PXCMImage.ImageData data;

image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB24, out data);

form.DisplayBitmap(data.ToBitmap(0, image.info.width, image.info.height));

image.ReleaseAccess(data);

image.Dispose();

在原始文章中檢視解決方案

11 回應
MartyG
榮譽貢獻者 III
388 檢視

When you say "memory overload", do you mean the "out of memory" error in Visual Studio 2015?

If you are using the instruction CreateColorImageMappedToDepth or CreateColorImageMappedToColor, these instructions have a known issue with a 'memory leak' that uses up memory over time whilst the program is running until the program crashes. The only solution is to use a different instruction that does not have the leak.

I recommend using the QueryVertices instruction instead to calculate vertices from the depth image.

https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/queryvertices_pxcprojection.html QueryVertices

ewu12
新手
388 檢視

Hi, MartyG

yes, it's "out of memory" error .

I try to only read RGB stream to display, but it's still show "out of memory" message.

no calculate no algorithm

MartyG
榮譽貢獻者 III
388 檢視

Could you give more details please about the RealSense script that you are using with Visual Studio 2015, and post it in your message or link to it if it is listed on a website? Is it the 'Rawstreams' sample? Thanks!

jb455
傑出貢獻者 II
388 檢視

Make sure you're calling https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?releaseframe_pxcsensemanager.html ReleaseFrame after QuerySample, https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?dispose_pxcmbase.html Dispose after any CreateX methods (eg, CreateProjection, CreateColorImageMappedToDepth etc - not immediately after, but when you're finished with the result for this frame), and https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?releaseaccess_pxcimage.html ReleaseAccess after AcquireAccess to avoid memory building up. If you're just doing simple streaming, your code should look something like this:

PXCMCapture.Sample photo = pSenseManager.QuerySample();

PXCMImage image = photo.color;

pSenseManager.ReleaseFrame();

PXCMImage.ImageData data;

image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB24, out data);

form.DisplayBitmap(data.ToBitmap(0, image.info.width, image.info.height));

image.ReleaseAccess(data);

image.Dispose();

idata
員工
388 檢視

Hi Edison_Wu

 

 

Do you still need assistance with this thread?

 

We'll be waiting for your response.

 

 

-Sergio A

 

ewu12
新手
388 檢視

Hi, jb455 & MartyG

thanks for your reply .

I think that it's problem about thread .

when I comment the "thread.start" ,and running application . the memory isn't increases.

and then i un-comment "thread.start" and comment most of code, the memory is increases.

it's my testing code below ,i will try it form jb455.

Thanks for everyone Help.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows.Forms;

using System.Drawing.Imaging;

namespace SR300_study

{

public partial class Form1 : Form

{

public int WIDTH = 640;

public int HEIGHT = 480;

public PXCMSession g_session;

public Form1()

{

Form1.CheckForIllegalCrossThreadCalls = false;

InitializeComponent();

pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBox1_Paint);

}

private void button1_Click(object sender, EventArgs e)

{

System.Threading.Thread thread = new System.Threading.Thread(RGB_DoRecognition);

thread.Start();

//System.Threading.Thread.Sleep(1000);

}

public void RGB_DoRecognition()

{

PXCMSenseManager sm = PXCMSenseManager.CreateInstance();

if (sm == null)

{

MessageBox.Show("sm is null");

}

sm.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, WIDTH, HEIGHT, 30);

sm.Init();

while (sm.AcquireFrame(true).IsSuccessful())

{

PXCMCapture.Sample sample = sm.QuerySample();

PXCMImage.ImageData data= null;

pxcmStatus ret = sample.color.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB24, out data);

if (ret == pxcmStatus.PXCM_STATUS_NO_ERROR)

{

//delete most of the code

}

sm.ReleaseFrame();

}

}

}

}

MartyG
榮譽貢獻者 III
388 檢視

Thanks so much for sharing this with the community, Edison_Wu

jb455
傑出貢獻者 II
388 檢視

The https://software.intel.com/sites/landingpage/realsense/camera-sdk/v1.1/documentation/html/index.html?acquireframe_pxcsensemanager.html docs for AcquireFrame recommend calling ReleaseFrame as soon as possible, without much processing going on in between. I'd suggest, like in my snippet above, taking a copy of the image(s) you need from the sample and calling ReleaseFrame immediately after that. Also be sure to call colourImage.ReleaseAccess(data), and also colourImage.Dispose(), when you are finished with the image data and the image itself.

idata
員工
388 檢視

Hi Edison_Wu,

 

 

It's great to hear you managed to resolve this issue. Feel free to contact us again if help is needed.

 

 

@MartyG and @jb455. Thanks so much for helping out!

 

 

Regards,

 

-Sergio A

 

ewu12
新手
388 檢視

Hi, all

Thanks for everyone help.

I have solved this problem.

@jb455 is right . I did't release image data ,then add below the code in my code .The memory didn't increases.

  1. image.ReleaseAccess(data);
  2. image.Dispose();

"

MartyG
榮譽貢獻者 III
388 檢視

Great news, thanks for letting us know!

回覆