Quantcast
Channel: Intel Developer Zone Articles
Viewing all articles
Browse latest Browse all 536

Intel® RealSense™ Depth Camera R200 Code Sample – Face Tracking

$
0
0

Download R200 Camera Face Tracking Code Sample

Introduction

This C#/XAML code sample demonstrates the basics of using the face tracking algorithm in the Intel® RealSense™ SDK for Windows* to detect and track a person’s face in real time using the R200 camera. The code sample performs the following functions:

  • Displays the live color stream of the R200 RGB camera in an Image control
  • Superimposes a rectangle control that tracks the user’s face (based on his or her appearance in the scene)
  • Displays the number of faces detected by the R200 camera
  • Displays the height and width of the tracked face
  • Displays the 2D coordinates (X and Y) of the tracked face
  • Indicates the face depth or distance between the face and the R200 camera
  • Enables and displays alert monitoring and subscribes to an alert event handler

Face Tracking Code Sample
Figure 1. Face Tracking Code Sample

Software Development Environment

The code sample is created on Windows® 10 RTM using Microsoft Visual Studio* Community 2015. The project template used for this sample is Visual C#WindowsClassic Desktop.

The SDK and DCM versions used in this project are:

  • Intel® RealSense™ SDK                                                       v6.0.21.6598
  • Intel® RealSense™ Depth Camera Manager R200              v2.0.3.39488

Hardware Overview

For this development work we used the Intel® RealSense™ Developer Kit (R200) with the camera mounted to a standard tripod using an optional magnetic mount** (Figure 2).

Camera Attached to Optional Magnetic Mount
Figure 2. Camera Attached to Optional Magnetic Mount**

(**May not be available in all kits.)

The basic 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 in the client system (do not use a hub).

 

Build Notes

  1. The project uses the System.Drawing.Imaging namespace, which is referenced manually in a new project by right-clicking References in Solution Explorer and then selecting Add Reference… to open the Reference Manager window. Next, select Assemblies, Framework and then search the list for System.Drawing. Highlight the checkbox and then click the OK button.
  2. The project uses an explicit path to libpxcclr.cs.dll (the managed DLL) located here: C:\Program Files (x86)\Intel\RSSDK\bin\x64. You will need to change this reference if your SDK installation path is different.
  3. Since this project is referencing the 64-bit version of the DLL, you must ensure that “x64” is specified under the ProjectPropertiesPlatform target setting.
  4. The project includes a post-build event command to ensure the unmanaged DLL (libpxccpp2c.dll) gets copied to the output target directory:
    if "$(Platform)" == "x86" (copy /y "$(RSSDK_DIR)\bin\win32\libpxccpp2c.dll""$(TargetDir)" ) else ( copy /y "$(RSSDK_DIR)\bin\x64\libpxccpp2c.dll""$(TargetDir)" )

About the Code

The code sample has the following structure:

  • Configure the Session, SenseManager interface, and face module.
  • 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.
    • Get face module 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. 


Viewing all articles
Browse latest Browse all 536

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>