📜 ⬆️ ⬇️

Intel RealSense R200 Camera - Code Samples



For programmers who have recently started working with Intel RealSense technology, we have prepared a post with three simple examples demonstrating the capabilities of the R200 camera. Examples include:


Record and view the raw streams of the R200 camera


This downloadable code demonstrates the basics of capturing and viewing the raw streams of the R200 camera on C # / XAML using the Intel® RealSense ™ SDK for Windows * . The Visual Studio * solution consists of four simple projects (the size of each is no more than 200 lines of code).


Figure 1. Sample code for all threads

Software development environment


This sample code was created in Windows® 10 RTM using Microsoft Visual Studio Community 2015. For this sample, we used the Visual C # project template - Windows - Classic Desktop .
The SDK and DCM versions used in this project.

Equipment description


For this work, we used the Intel® RealSense ™ Developer Kit (R200) , which includes a camera, a USB3 cable and a magnetic mount for installing the camera on a laptop (Fig. 2).
')

Figure 2. Intel® RealSense ™ Developer Kit (R200)

For sample code R200, the following hardware requirements apply:

Important! To support the data stream transmitted by the camera, a USB3 interface is required. This interface must be connected to a dedicated USB3 port on the client system (without using a splitter).

Code Description


The solution in Visual Studio consists of four WPF projects developed in C #. These projects use an explicit path to the libpxcclr.cs.dll (managed DLL):

C: \ Program Files (x86) \ Intel \ RSSDK \ bin \ x64

Remember to change this path if the SDK is installed in a different folder on your system.
Since we are launching the 64-bit version of the DLL, go to Project → Properties → Platform target and make sure that the value “x64” is selected.
To build and run a specific project, right-click the project name (for example, AllStreams) in Solution Explorer (Solution Explorer) and choose Set as StartUp Project from the menu.

All projects within the CameraStreams solution have a similar structure.

Configure the Session and SenseManager interface.

Start a workflow called Update , which processes the AcquireFrame - ReleaseFrame cycle .

In the AcquireFrame - ReleaseFrame loop , the following actions occur.

In the Render method, the following actions occur.

The ShutDown method is called whenever the Window_Closing or btnExit_Click events occur . In the ShutDown method, the following actions occur.


Changing the depth focus


This C # / XAML code example demonstrates the basics of working with the Enhanced Photography (EP) module in the Intel® RealSense ™ SDK for Windows * to change the focus of an image after it is taken. This sample code performs the following actions.


Figure 3. An example of changing the depth focusing (focusing on a flower)


Figure 4. Saved image file

As described in the SDK manual (in the file RSSDK_DIR \ doc \ PDF \ sdkmanuals.pdf ), the Enhanced Photography (EP) module extends traditional photo and video processing capabilities by using three-dimensional information (in particular, depth data) recorded with photos and videos. The function of changing the depth of field changes the focus and depth of field of the frame after shooting it. (Please note that this algorithm only works with the R200 camera.)

Equipment description


We used the Intel® RealSense ™ Developer Kit (R200) ​​for this job. The camera was mounted on a laptop using the magnetic mount included in the kit (Fig. 5).


Figure 5. Camera attached to magnetic mount

Build Notes


This project uses the System.Drawing.Imaging namespace. The link to it is specified manually: in the new project, right-click on References in the Solution Explorer and select Add Reference ... to open the link manager window. Then select Assemblies, Framework , and find System.Drawing in the list. Check the box and click OK.

This project uses an explicit path to the libpxcclr.cs.dll (managed DLL): C: \ Program Files (x86) \ Intel \ RSSDK \ bin \ x64 . Remember to change this path if the SDK is installed in a different folder on your system.

Since the project refers to the 64-bit version of the DLL, make sure that the "x64" parameter is specified in Project → Properties → Platform target .

The project includes a post-build event command to ensure that the unmanaged DLL (libpxccpp2c.dll) is copied to the target output folder:
if "$(Platform)" == "x86" (copy /y "$(RSSDK_DIR)\bin\win32\libpxccpp2c.dll" "$(TargetDir)" ) else ( copy /y
"$(RSSDK_DIR)\bin\x64\libpxccpp2c.dll" "$(TargetDir)" )


Face tracking


This C # / XAML code example demonstrates the basics of working with the face tracking algorithm in the Intel® RealSense ™ SDK for Windows * to detect and track people's faces in real time using the R200 camera. This sample code performs the following actions.


Figure 6. Sample face tracking code

Equipment description


We used the Intel® RealSense ™ Developer Kit (R200) ​​for this job. The camera was mounted on a standard tripod using an optional magnetic mount ** (Fig. 7).


Figure 7. Camera attached to a magnetic mount (may not be available in all kits)

Build Notes


See the previous example.

Code Description


The sample code has the following structure.

Configure the Session and SenseManager interface, as well as the face recognition module.
Start a workflow called Update , which processes the AcquireFrame - ReleaseFrame cycle .
In the AcquireFrame - ReleaseFrame loop , the following actions occur.

In the Render method, the following actions occur.

The ShutDown method is called whenever the Window_Closing or btnExit_Click events occur . In the ShutDown method, the following actions occur.

Source: https://habr.com/ru/post/269253/


All Articles