Code, Computer Vision, Technology And Science

[RealSense SDK] Stream Color and Depth Camera Simultaneously

In this post, I will describe how to stream altogether color and depth stream of Intel RealSense 3D camera SR300. This can be done easily by using RealSense SDK. However for new developers who have not familiarized them-self with the SDK, this task might not be easy to do.

Here is the initial steps that we must follow to stream images from RealSense 3D camera:

//Step 1: Create SenseManager instance
PXCMSenseManager senseMgr = PXCMSenseManager.CreateInstance();
//Step 2: Enable color and depth stream
senseMgr.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 30);
senseMgr.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 640, 480, 30);
//Step 3: Initialize SenseManager
senseMgr.Init();

After that, we can use either a callback or worker thread to capture every frame from the camera. In this case, I will implement it using a worker thread.


private void CaptureFrames()

{
while(isRunning)

{

if (senseMgr.AcquireFrame(true).IsError()) break;

PXCMCapture.Sample sample = senseMgr.QuerySampe();

if (sampe != null)

{

PXCMImage colorImage = sample.color;

PXCMImage depthImage = sample.depth;

}

senseMgr.ReleaseFrame();

}

senseMgr.Close();
}

The above function CaptureFrames can be passed to a worker thread, so that we can stream both color and depth frames continuously.

One thought on “[RealSense SDK] Stream Color and Depth Camera Simultaneously

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s