コード例 #1
0
    private void DrawResults(FaceDetect.Result faceDetectionResult,
                             FaceMesh.Result faceMesh,
                             IrisDetect.Result irisLeftResult,
                             IrisDetect.Result irisRightResult)
    {
        viewWebCam.rectTransform.GetWorldCorners(m_rtCorners);
        Vector3 min = m_rtCorners[0];
        Vector3 max = m_rtCorners[2];

        float zScale = (max.x - min.x) / 2;

        Color32 faceMeshDetectColor = new Color32(30, 150, 255, 255);
        Color32 eyeDetectColor      = new Color32(255, 255, 0, 255);
        Color32 irisDetectColor     = new Color32(255, 0, 0, 255);

        // TODO check why 6 landmarks are not showing up properly
        //DrawFaceDetection(faceDetectionResult, min, max, new Color32(80,200,255,255), 0.05f);

        DrawFaceMeshDetection(faceMesh, min, max, faceMeshDetectColor, zScale, 0.035f);

        DrawEyeDetection(min, max, irisLeftResult, irisRightResult, eyeDetectColor, zScale, 0.035f);

        DrawIrisDetection(min, max, irisLeftResult, irisRightResult, irisDetectColor, zScale, 0.035f);

        //TODO uncomment this to show up mesh
        //RenderFaceMesh();
    }
コード例 #2
0
    private void DrawIrisDetection(Vector3 min, Vector3 max,
                                   IrisDetect.Result irisLeftResult,
                                   IrisDetect.Result irisRightResult,
                                   Color32 color, float zScale, float pntSize)
    {
        LerpPointArray(irisLeftResult.irislandmark, min, max, zScale, pntSize, color, "IrisL");

        LerpPointArray(irisRightResult.irislandmark, min, max, zScale, pntSize, color, "IrisR");
    }
コード例 #3
0
    private void DrawEyeDetection(Vector3 min, Vector3 max,
                                  IrisDetect.Result irisLeftResult,
                                  IrisDetect.Result irisRightResult,
                                  Color32 color, float zScale, float pntSize)
    {
        // int[] eye_idx0 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

        LerpPointArray(irisLeftResult.eyelandmark, min, max, zScale, pntSize, color, "EyeL");

        LerpPointArray(irisRightResult.eyelandmark, min, max, zScale, pntSize, color, "EyeR");
    }
コード例 #4
0
    void Update()
    {
        //////////////////////////////////////////////////////////////////////////////////////////
        // Face Detection

        // TODO: detected points should be 6 and it works for the first run but then they are only 2
        if (m_faceDetectionResult == null || !useLandmarkToDetection)
        {
            m_faceDetect.Invoke(m_webcamTexture);

            viewWebCam.material = m_faceDetect.transformMat;

            m_faceDetectionResult = m_faceDetect.GetResults().FirstOrDefault();


            if (m_faceDetectionResult == null)
            {
                return;
            }
        }

        //////////////////////////////////////////////////////////////////////////////////////////
        // Face Mesh Landmarks Detection

        m_faceMesh.Invoke(m_webcamTexture, m_faceDetectionResult);

        viewFaceDetect.texture = m_faceMesh.inputTex;


        var faceMeshResult = m_faceMesh.GetResult();

        if (faceMeshResult.score < 0.5f)
        {
            m_faceDetectionResult = null;
            return;
        }

        //////////////////////////////////////////////////////////////////////////////////////////
        // Eye and Iris Landmarks Detection

        int[] indxLeftEye  = { 33, 133 };
        int[] indxRightEye = { 362, 263 };


        m_irisLeftDetect.Invoke(m_webcamTexture, indxLeftEye, m_faceDetectionResult, faceMeshResult, 1);
        m_irisRightDetect.Invoke(m_webcamTexture, indxRightEye, m_faceDetectionResult, faceMeshResult, -1);

        viewEyeLeft.texture  = m_irisLeftDetect.inputTex;
        viewEyeRight.texture = m_irisRightDetect.inputTex;

        m_irisLeftResult  = m_irisLeftDetect.GetResult(1);
        m_irisRightResult = m_irisRightDetect.GetResult(-1);

        //////////////////////////////////////////////////////////////////////////////////////////
        // Draw Results

        DrawResults(m_faceDetectionResult, faceMeshResult, m_irisLeftResult, m_irisRightResult);

        if (useLandmarkToDetection)
        {
            m_faceDetectionResult = m_faceMesh.LandmarkToDetection(faceMeshResult);
        }
    }