void DrawResults(FaceDetect.Result detection, FaceMesh.Result face) { cameraView.rectTransform.GetWorldCorners(rtCorners); Vector3 min = rtCorners[0]; Vector3 max = rtCorners[2]; // Draw Face Detection { draw.color = Color.blue; Rect rect = MathTF.Lerp(min, max, detection.rect, true); draw.Rect(rect, 0.05f); foreach (Vector2 p in detection.keypoints) { draw.Point(MathTF.Lerp(min, max, new Vector3(p.x, 1f - p.y, 0)), 0.1f); } } draw.Apply(); // Draw face draw.color = Color.green; float zScale = (max.x - min.x) / 2; for (int i = 0; i < face.keypoints.Length; i++) { Vector3 p = MathTF.Lerp(min, max, face.keypoints[i]); p.z = face.keypoints[i].z * zScale; faceKeypoints[i] = p; draw.Point(p, 0.05f); } draw.Apply(); // Update Mesh FaceMeshBuilder.UpdateMesh(faceMeshFilter.sharedMesh, faceKeypoints); }
private void DrawResult(MoveNet.Result[] results) { if (results == null || results.Length == 0) { return; } var rect = cameraView.GetComponent <RectTransform>(); rect.GetWorldCorners(rtCorners); Vector3 min = rtCorners[0]; Vector3 max = rtCorners[2]; var connections = PoseNet.Connections; int len = connections.GetLength(0); for (int i = 0; i < len; i++) { var a = results[(int)connections[i, 0]]; var b = results[(int)connections[i, 1]]; if (a.confidence >= threshold && b.confidence >= threshold) { draw.Line3D( MathTF.Lerp(min, max, new Vector3(a.x, 1f - a.y, 0)), MathTF.Lerp(min, max, new Vector3(b.x, 1f - b.y, 0)), 1 ); } } draw.Apply(); }
void DrawResult() { var rect = cameraView.GetComponent <RectTransform>(); rect.GetWorldCorners(corners); Vector3 min = corners[0]; Vector3 max = corners[2]; var connections = PoseNet.Connections; int len = connections.GetLength(0); for (int i = 0; i < len; i++) { var a = results[(int)connections[i, 0]]; var b = results[(int)connections[i, 1]]; if (a.confidence >= threshold && b.confidence >= threshold) { draw.Line3D( MathTF.Lerp(min, max, new Vector3(a.x, 1f - a.y, 0)), MathTF.Lerp(min, max, new Vector3(b.x, 1f - b.y, 0)), lineThickness ); } } draw.Apply(); }
void DrawFrame(ref PoseDetect.Result pose) { Vector3 min = rtCorners[0]; Vector3 max = rtCorners[2]; draw.color = Color.green; draw.Rect(MathTF.Lerp(min, max, pose.rect, true), 0.02f, min.z); foreach (var kp in pose.keypoints) { draw.Point(MathTF.Lerp(min, max, (Vector3)kp, true), 0.05f); } draw.Apply(); }
private void LerpPointArray(Vector3[] keypoints, Vector3 min, Vector3 max, float zScale, float pntSize, Color32 color, string detectionType) { for (int i = 0; i < keypoints.Length; i++) { Vector3 p = MathTF.Lerp(min, max, new Vector3(keypoints[i].x, keypoints[i].y, keypoints[i].z)); p.z = keypoints[i].z * zScale; switch (detectionType) { case ("FACE"): m_faceKeypoints[i] = p; break; case ("EyeR"): m_irisRightResult.eyelandmark[i] = p; break; case ("EyeL"): m_irisLeftResult.eyelandmark[i] = p; break; case ("IrisR"): m_irisRightResult.irislandmark[i] = p; break; case ("IrisL"): m_irisLeftResult.irislandmark[i] = p; break; } m_drawPrimitive.Point(p, pntSize); } m_drawPrimitive.color = color; m_drawPrimitive.Apply(); }
void DrawFrames(List <PalmDetect.Result> palms) { Vector3 min = rtCorners[0]; Vector3 max = rtCorners[2]; draw.color = Color.green; foreach (var palm in palms) { draw.Rect(MathTF.Lerp(min, max, palm.rect, true), 0.02f, min.z); foreach (var kp in palm.keypoints) { draw.Point(MathTF.Lerp(min, max, (Vector3)kp, true), 0.05f); } } draw.Apply(); }
void DrawResults(List <FaceDetect.Result> results) { Vector3 min = rtCorners[0]; Vector3 max = rtCorners[2]; draw.color = Color.blue; foreach (var result in results) { Rect rect = MathTF.Lerp(min, max, result.rect, true); draw.Rect(rect, 0.05f); foreach (Vector2 p in result.keypoints) { draw.Point(MathTF.Lerp(min, max, new Vector3(p.x, 1f - p.y, 0)), 0.1f); } } draw.Apply(); }