Example #1
0
    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();
    }
    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();
    }
Example #4
0
    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();
    }