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); }
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(); }
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(); }
private void DrawFaceDetection(FaceDetect.Result detection, Vector3 min, Vector3 max, Color color, float pntSize) { // Draw Face Detection m_drawPrimitive.color = color; UnityEngine.Rect rect = MathTF.Lerp(min, max, detection.rect, true); m_drawPrimitive.Rect(rect, 0.03f); float zScale = (max.x - min.x) / 2; for (int i = 0; i < detection.keypoints.Length; i++) { Vector3 p = MathTF.Lerp(min, max, new Vector3(detection.keypoints[i].x, 1f - detection.keypoints[i].y, 0)); //Debug.Log("Detection Pnts: " + detection.keypoints.Length + "\n"); m_drawPrimitive.Point(p, pntSize); } m_drawPrimitive.Apply(); }