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.
.
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();
連結已複製
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
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();
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();
}
}
}
}
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.