title: Face Recognition with Unity and SDK Watson
body: <p>I would like to do facial recognition with the feed of the camera of my computer with Unity and SDK Watson. I looked for some tutorials and demos in the internet and I think finally get it. This is one of my first projects in Unity so I would be so grateful if someone could help me to correct two errors I cannot fix. </p>
  
  <p>I use this code for camera render and capture the image:</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  
  public class CameraRender : MonoBehaviour {
  public Image overlay;
  public FaceDetector fd;
  
  // Use this for initialization
  void Start () {
      WebCamTexture backCam = new WebCamTexture();
      backCam.Play();
      overlay.material.mainTexture = backCam;
  }
  
  public void CaptureImage()
  {
      ScreenCapture.CaptureScreenshot(Application.persistentDataPath + "/screenshot.png");
      fd.DetectFaces(Application.persistentDataPath + "/screenshot.png");
  }
  
  // Update is called once per frame
  void Update () {
      if (Input.GetMouseButtonDown(0))
      {
          CaptureImage();
      }
  }
  }
  </code></pre>
  
  <p>And this other one for face detection:</p>
  
  <pre><code>using IBM.Watson.DeveloperCloud.Connection;
  using IBM.Watson.DeveloperCloud.Logging;
  using IBM.Watson.DeveloperCloud.Services.VisualRecognition.v3;
  using IBM.Watson.DeveloperCloud.Utilities;
  using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  
  public class FaceDetector : MonoBehaviour {
  
  public Text dataOutput;
  
  private VisualRecognition _visualRecognition;
  
  // Use this for initialization
  void Start ()
  {
      Credentials credentials = new Credentials(apiKey: "key", url: "url");
      _visualRecognition = new ExampleVisualRecognition(credentials)
      {
          VersionDate = "2016-05-20"
      };
  }
  
  public void DetectFaces(string path)
  {
      //  Classify using image url
      //if (!_visualRecognition.DetectFaces("&lt;image-url&gt;", OnDetectFaces, OnFail))
      //    Log.Debug("ExampleVisualRecognition.DetectFaces()", "Detect faces failed!");
  
      //  Classify using image path
  
      if (!_visualRecognition.DetectFaces(OnDetectFaces, OnFail, path)) { 
          Log.Debug("ExampleVisualRecognition.DetectFaces()", "Detect faces failed!");
      } else
      {
          Debug.Log("Calling Watson");
          dataOutput.text = "";
      }
  }
  
  private void OnDetectFaces(DetectedFaces multipleImages, Dictionary&lt;string, object&gt; customData)
  {
      var data = multipleImages.images[0].faces[0]; //assume 1
      dataOutput.text = "Age : " + data.age.min + "-" + data.age.max + " PROBABILITY: " + data.age.score + "\n" + "Gender" + data.gender.gender + " PROBABILITY: " + data.age.score + "\n";
      Log.Debug("ExampleVisualRecognition.OnDetectFaces(): Detect faces result: {0}", customData["json"].ToString());
  }
  
  private void OnFail(RESTConnector.Error error, Dictionary&lt;string,object&gt; customData)
  {
      Debug.LogError("ExampleVisualRecognition.OnFail(): Error received: " + error.ToString());
  }
  
  // Update is called once per frame
  void Update () {
  
  }
  }
  </code></pre>
  
  <p>But I cannot fix this two errors:</p>
  
  <pre><code>NotImplementedException: The requested feature is not implemented. IBM.Watson.DeveloperCloud.Services.VisualRecognition.v3.VisualRecognition.op_Implicit (.ExampleVisualRecognition v) (at Assets/Watson/Scripts/Services/VisualRecognition/v3/VisualRecognition.cs:1444)
  FaceDetector.Start () (at Assets/FaceDetector.cs:21)
  
  NullReferenceException: Object reference not set to an instance of an object
  FaceDetector.DetectFaces (System.String path) (at Assets/FaceDetector.cs:35)
  CameraRender.CaptureImage () (at Assets/CameraRender.cs:20)
  CameraRender.Update () (at Assets/CameraRender.cs:27)
  </code></pre>
  
  <p>Could someone bring some help? Thank you all.</p>