// performs face detection private IEnumerator DoFaceDetection() { // get the image to detect faces = null; Texture2D texCamShot = null; if (cameraShot) { texCamShot = (Texture2D)cameraShot.GetComponent <Renderer>().material.mainTexture; //SetHintText("Wait..."); } // get the face manager instance CloudFaceManager faceManager = CloudFaceManager.Instance; if (texCamShot && faceManager) { if (faces != null && faces.Length > 0) { //if(displayFaceRectangles) { //faceManager.DrawFaceRects(texCamShot, faces, FaceDetectionUtils.FaceColors, this.displayHeadDirection); faceManager.AddFaceToList(texCamShot, faces); } //Add most promininent face to faceList. //SetHintText("Click on the camera image to make a shot"); } else { //SetHintText("No faces detected."); } yield return(faceManager.DetectFaces(texCamShot)); faces = faceManager.faces; } else { //SetHintText("Check if the FaceManager component exists in the scene."); } yield return(null); }
// performs face detection private IEnumerator DoFaceDetection() { // get the image to detect Face[] faces = null; Texture2D texCamShot = null; if (cameraShot) { texCamShot = (Texture2D)cameraShot.material.mainTexture; SetHintText("Wait..."); } // get the face manager instance CloudFaceManager faceManager = CloudFaceManager.Instance; if (!faceManager) { SetHintText("Check if the FaceManager component exists in the scene."); } else if (texCamShot) { yield return(faceManager.DetectFaces(texCamShot)); faces = faceManager.faces; if (faces != null && faces.Length > 0) { //if(displayFaceRectangles) { faceManager.DrawFaceRects(texCamShot, faces, FaceDetectionUtils.FaceColors, displayHeadDirection); faceManager.AddFaceToList(texCamShot, faces); } SetHintText(hintMessage); SetResultText(faces); } else { SetHintText("No face(s) detected."); } } yield return(null); }