<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Hi Shivang, in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Face-Tracking-Crashes-Unity-Unity-not-responding/m-p/1013759#M35205</link>
    <description>&lt;P&gt;Hi Shivang,&lt;/P&gt;

&lt;P&gt;You'll also want to study the Unity examples provided in the RSSDK to see how the AcquireFrame method is called in a Unity script's Update() method, as opposed to a continuous thread as shown in the C#/XAML sample you've copied the code from.&lt;/P&gt;

&lt;P&gt;-Bryan&lt;/P&gt;</description>
    <pubDate>Mon, 12 Oct 2015 16:59:38 GMT</pubDate>
    <dc:creator>Bryan_B_Intel1</dc:creator>
    <dc:date>2015-10-12T16:59:38Z</dc:date>
    <item>
      <title>Face Tracking Crashes Unity / Unity not responding</title>
      <link>https://community.intel.com/t5/Software-Archive/Face-Tracking-Crashes-Unity-Unity-not-responding/m-p/1013757#M35203</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to run Face tracking using following code but Unity is crashing without any error or response:&lt;/P&gt;

&lt;PRE class="brush:csharp;"&gt;using UnityEngine;

using System;

using System.Collections;

using System.Collections.Generic;

using System.Threading;

public class FaceDetection : BaseAction {

	private PXCMSession session;
    private PXCMSenseManager senseManager;
    private PXCMFaceData faceData;
    private Thread update;
    private string alertMsg;


	void Start(){
		// Start SenseManager and configure the face module
            ConfigureRealSense();

        // Start the Update thread
            update = new Thread(new ThreadStart(Update));
            update.Start();
	}	
	
	// Use this for initialization
	void Update () {
		Int32 facesDetected = 0;
        Int32 faceH = 0;
        Int32 faceW = 0;
        Int32 faceX = 0;
        Int32 faceY = 0;
        float faceDepth = 0;

        // Start AcquireFrame-ReleaseFrame loop
        while (senseManager.AcquireFrame(true) &amp;gt;= pxcmStatus.PXCM_STATUS_NO_ERROR)
        {
            // Acquire color image data
            PXCMCapture.Sample sample = senseManager.QuerySample();
            //Bitmap colorBitmap;
            PXCMImage.ImageData colorData;
            sample.color.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB32, out colorData);
            //colorBitmap = colorData.ToBitmap(0, sample.color.info.width, sample.color.info.height);

            // Acquire face data
            if (faceData != null)
            {
                faceData.Update();
                facesDetected = faceData.QueryNumberOfDetectedFaces();

                if (facesDetected &amp;gt; 0)
                {
                    // Get the first face detected (index 0)
                    PXCMFaceData.Face face = faceData.QueryFaceByIndex(0);

                    // Retrieve face location data
                    PXCMFaceData.DetectionData faceDetectionData = face.QueryDetection();
                    if (faceDetectionData != null)
                    {
                        PXCMRectI32 faceRectangle;
                        faceDetectionData.QueryBoundingRect(out faceRectangle);
                        faceH = faceRectangle.h;
                        faceW = faceRectangle.w;
                        faceX = faceRectangle.x;
                        faceY = faceRectangle.y;

                        // Get average depth value of detected face
                        faceDetectionData.QueryFaceAverageDepth(out faceDepth);
                    }
                }
            }

            // Update UI
            //Render(colorBitmap, facesDetected, faceH, faceW, faceX, faceY, faceDepth);
            Debug.Log("Face height " + faceH);
            // Release the color frame
            //colorBitmap.Dispose();
            sample.color.ReleaseAccess(colorData);
            senseManager.ReleaseFrame();
        }
	}

/*	private void Render(Bitmap bitmap, Int32 count, Int32 h, Int32 w, Int32 x, Int32 y, float depth)
        {
            Debug.Log("object message");
        }
        */
        
    private void FaceAlertHandler(PXCMFaceData.AlertData alert){
        alertMsg = Convert.ToString(alert.label);
    }

	private void ConfigureRealSense()
        {
            PXCMFaceModule faceModule;
            PXCMFaceConfiguration faceConfig;

            // Start the SenseManager and session  
            session = PXCMSession.CreateInstance();
            senseManager = session.CreateSenseManager();

            // Enable the color stream
            senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 480, 30);

            // Enable the face module
            senseManager.EnableFace();
            faceModule = senseManager.QueryFace();
            faceConfig = faceModule.CreateActiveConfiguration();

            // Configure for 3D face tracking
            faceConfig.SetTrackingMode(PXCMFaceConfiguration.TrackingModeType.FACE_MODE_COLOR_PLUS_DEPTH);

            // Known issue: Pose isEnabled must be set to false for R200 face tracking to work correctly
            faceConfig.pose.isEnabled = false;

            // Track faces based on their appearance in the scene
            faceConfig.strategy = PXCMFaceConfiguration.TrackingStrategyType.STRATEGY_APPEARANCE_TIME;
            
            // Set the module to track four faces in this example
            faceConfig.detection.maxTrackedFaces = 4;

            // Enable alert monitoring and subscribe to alert event hander
            faceConfig.EnableAllAlerts();
            faceConfig.SubscribeAlert(FaceAlertHandler);

            // Apply changes and initialize
            faceConfig.ApplyChanges();
            senseManager.Init();
            faceData = faceModule.CreateOutput();

            // Mirror the image
            senseManager.QueryCaptureManager().QueryDevice().SetMirrorMode(PXCMCapture.Device.MirrorMode.MIRROR_MODE_HORIZONTAL);

            // Release resources
            faceConfig.Dispose();
            faceModule.Dispose();
        }

        private void OnDestroy(){
            // Stop the Update thread
            update.Abort();

            // Dispose RealSense objects
            faceData.Dispose();
            senseManager.Dispose();
            session.Dispose();
        }

}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;The code I have modified from the following link:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://software.intel.com/en-us/articles/intel-realsense-depth-camera-r200-code-sample-face-tracking"&gt;https://software.intel.com/en-us/articles/intel-realsense-depth-camera-r200-code-sample-face-tracking&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I am new at Unity and Intel RealSense and I am not aware how to structure the code. Any help with the above code or links for tutorial would be great.&lt;BR /&gt;
	&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;
	&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;Shivang&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Oct 2015 19:24:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Face-Tracking-Crashes-Unity-Unity-not-responding/m-p/1013757#M35203</guid>
      <dc:creator>Shivang_D_</dc:creator>
      <dc:date>2015-10-11T19:24:54Z</dc:date>
    </item>
    <item>
      <title>Hi Shivang,</title>
      <link>https://community.intel.com/t5/Software-Archive/Face-Tracking-Crashes-Unity-Unity-not-responding/m-p/1013758#M35204</link>
      <description>&lt;P&gt;Hi Shivang,&lt;/P&gt;

&lt;P&gt;Can you please provide the following:&lt;/P&gt;

&lt;P&gt;1. The version of SDK and DCM are you running.&lt;BR /&gt;
	2. Verify you are using the rear facing R200 camera, not the forward facing F200 (the sample you're referencing is targeting the R200).&lt;BR /&gt;
	3. Ensure your system meets the requirements listed here: &lt;A href="https://software.intel.com/en-us/realsense/devkit" target="_blank"&gt;https://software.intel.com/en-us/realsense/devkit&lt;/A&gt;?&lt;/P&gt;

&lt;P&gt;Also, if you have recently upgraded the SDK version on your dev system, did you ensure that your Unity project was also updated to use the most recent DLLs?&lt;/P&gt;

&lt;P&gt;This information will help in troubleshooting the problem.&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
	Bryan&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2015 16:47:46 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Face-Tracking-Crashes-Unity-Unity-not-responding/m-p/1013758#M35204</guid>
      <dc:creator>Bryan_B_Intel1</dc:creator>
      <dc:date>2015-10-12T16:47:46Z</dc:date>
    </item>
    <item>
      <title>Hi Shivang,</title>
      <link>https://community.intel.com/t5/Software-Archive/Face-Tracking-Crashes-Unity-Unity-not-responding/m-p/1013759#M35205</link>
      <description>&lt;P&gt;Hi Shivang,&lt;/P&gt;

&lt;P&gt;You'll also want to study the Unity examples provided in the RSSDK to see how the AcquireFrame method is called in a Unity script's Update() method, as opposed to a continuous thread as shown in the C#/XAML sample you've copied the code from.&lt;/P&gt;

&lt;P&gt;-Bryan&lt;/P&gt;</description>
      <pubDate>Mon, 12 Oct 2015 16:59:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Face-Tracking-Crashes-Unity-Unity-not-responding/m-p/1013759#M35205</guid>
      <dc:creator>Bryan_B_Intel1</dc:creator>
      <dc:date>2015-10-12T16:59:38Z</dc:date>
    </item>
  </channel>
</rss>

