|
22 | 22 | using IBM.Watson.DeveloperCloud.Services.VisualRecognition.v3; |
23 | 23 | using IBM.Watson.DeveloperCloud.Logging; |
24 | 24 |
|
| 25 | +/// <summary> |
| 26 | +/// This is an example class showing how to use Visual Recognition with the WebCam. |
| 27 | +/// </summary> |
25 | 28 | public class WebCamRecognition : MonoBehaviour |
26 | 29 | { |
27 | 30 | #region Private Data |
@@ -85,6 +88,8 @@ public void RecognizeText() |
85 | 88 | image.Apply(); |
86 | 89 |
|
87 | 90 | File.WriteAllBytes(filePath + fileName, image.EncodeToPNG()); |
| 91 | + |
| 92 | + Log.Debug("WebCamRecognition", "File writeen to {0}{1}", filePath, fileName); |
88 | 93 | } |
89 | 94 |
|
90 | 95 | private IEnumerator ClassifyImage() |
@@ -160,10 +165,15 @@ private void OnDetectFaces(FacesTopLevelMultiple multipleImages, string data) |
160 | 165 | Log.Debug("WebCamRecognition", "\tsource_url: {0}, resolved_url: {1}", faces.source_url, faces.resolved_url); |
161 | 166 | foreach (OneFaceResult face in faces.faces) |
162 | 167 | { |
163 | | - Log.Debug("WebCamRecognition", "\t\tFace location: {0}, {1}, {2}, {3}", face.face_location.left, face.face_location.top, face.face_location.width, face.face_location.height); |
164 | | - Log.Debug("WebCamRecognition", "\t\tGender: {0}, Score: {1}", face.gender.gender, face.gender.score); |
165 | | - Log.Debug("WebCamRecognition", "\t\tAge Min: {0}, Age Max: {1}, Score: {2}", face.age.min, face.age.max, face.age.score); |
166 | | - Log.Debug("WebCamRecognition", "\t\tName: {0}, Score: {1}, Type Heiarchy: {2}", face.identity.name, face.identity.score, face.identity.type_hierarchy); |
| 168 | + if(face.face_location != null) |
| 169 | + Log.Debug("WebCamRecognition", "\t\tFace location: {0}, {1}, {2}, {3}", face.face_location.left, face.face_location.top, face.face_location.width, face.face_location.height); |
| 170 | + if(face.gender != null) |
| 171 | + Log.Debug("WebCamRecognition", "\t\tGender: {0}, Score: {1}", face.gender.gender, face.gender.score); |
| 172 | + if(face.age != null) |
| 173 | + Log.Debug("WebCamRecognition", "\t\tAge Min: {0}, Age Max: {1}, Score: {2}", face.age.min, face.age.max, face.age.score); |
| 174 | + |
| 175 | + if(face.identity != null) |
| 176 | + Log.Debug("WebCamRecognition", "\t\tName: {0}, Score: {1}, Type Heiarchy: {2}", face.identity.name, face.identity.score, face.identity.type_hierarchy); |
167 | 177 | } |
168 | 178 | } |
169 | 179 | } |
|
0 commit comments