The Intel® RealSense™ SDK has been discontinued. No ongoing support or updates will be available.
This downloadable code sample demonstrates the basics of capturing and viewing raw R200 camera streams in C#/XAML using the Intel® RealSense™ SDK for Windows*. The Visual Studio* solution is actually comprised of four simple projects (each under 200 lines of code):
- ColorStream – Displays the color stream from the RGB camera
- DepthStream – Displays the depth stream
- IRStreams – Displays the left and right IR camera streams
- AllStreams – Shows all of the above in a single window (Figure 1)
Figure 1. All Streams Code Sample
Software Development Environment
The code sample was created on Windows® 10 RTM using Microsoft Visual Studio Community 2015. The project template used for this sample is Visual C# – Windows – Classic Desktop.
The SDK and DCM versions used in this project are:
- Intel® RealSense™ SDK v126.96.36.19998
- Intel® RealSense™ Depth Camera Manager R200 v188.8.131.52488
For this development work we used the Intel® RealSense™ Developer Kit (R200), which includes the camera, USB3 cable, and a magnetic adhesive mount for attaching the camera to a laptop computer (Figure 2).
Figure 2. Intel® RealSense™ Developer Kit (R200)
The hardware requirements for running the R200 code sample are as follows:
- 4th generation (or later) Intel® Core™ processor
- 150 MB free hard disk space
- 4GB RAM
- Intel® RealSense™ camera (R200)
- Available USB3 port for the R200 camera (or dedicated connection for integrated camera)
Important Note: A USB3 interface is required to support the bandwidth needed by the camera. This interface must be connected to a dedicated USB3 port within the client system (do not use a hub).
About the Code
The Visual Studio solution consists of four WPF projects developed in C#. These projects use an explicit path to libpxcclr.cs.dll (the managed DLL):
C:\Program Files (x86)\Intel\RSSDK\bin\x64
Note that this reference will need to be changed if your SDK installation path is different.
Since we are referencing the 64-bit version of the DLL, you must also ensure that “x64” is specified under the Project → Properties → Platform target setting.
To build and run a particular project, right-click on the project name (e.g., AllStreams) in Solution Explorer, then select Set as StartUp Project from the menu options.
All of the projects contained in the CameraStreams solution have a similar structure:
- Configure the Session and SenseManager interface.
- Start a worker thread named Update, in which the AcquireFrame-ReleaseFrame loop is processed.
- The following actions take place inside the AcquireFrame-ReleaseFrame loop:
- Get image data.
- Call the Render method to update the UI.
- Release resources.
- Release the frame.
- The following actions take place inside the Render method:
- Call the ConvertBitmap method to convert each bitmap frame to a BitmapImage type, which is required for displaying each frame in the WPF Image control.
- Update the UI by delegating work to the Dispatcher associated with the UI thread.
- A ShutDown method is called whenever the Window_Closing or btnExit_Click events fire. The following actions take place inside the ShutDown method:
- Stop the Update thread.
- Dispose objects.
Check It Out
Follow the Download link to get the code and experiment with this sample.
About Intel® RealSense™ Technology
To get started and learn more about the Intel RealSense SDK for Windows, go to https://software.intel.com/en-us/intel-realsense-sdk.
About the Author
Bryan Brown is a software applications engineer in the Developer Relations Division at Intel.