Exemplo n.º 1
0
    void Update()
    {
        palmDetect.Invoke(webcamTexture);
        cameraView.material = palmDetect.transformMat;

        var palms = palmDetect.GetResults(0.7f, 0.3f);

        UpdateFrame(palms);

        if (palms.Count <= 0)
        {
            if (landmarkResult != null)
            {
                landmarkResult.score = 0;
            }
            return;
        }

        // Detect only first palm
        landmarkDetect.Invoke(webcamTexture, palms[0]);
        debugPalmView.texture = landmarkDetect.inputTex;

        landmarkResult = landmarkDetect.GetResult();
        {
            // Apply webcam rotation to draw landmarks correctly
            Matrix4x4 mtx = WebCamUtil.GetMatrix(-webcamTexture.videoRotationAngle, false, webcamTexture.videoVerticallyMirrored);
            for (int i = 0; i < landmarkResult.joints.Length; i++)
            {
                landmarkResult.joints[i] = mtx.MultiplyPoint3x4(landmarkResult.joints[i]);
            }
        }

        RectTransformationCalculator.ApplyToRectTransform(landmarkDetect.CropMatrix, cropedFrame.rectTransform);
    }
Exemplo n.º 2
0
    void Update()
    {
        poseDetect.Invoke(webcamTexture);
        cameraView.material = poseDetect.transformMat;

        var pose = poseDetect.GetResults(0.7f, 0.3f);

        UpdateFrame(ref pose);

        if (pose.score < 0)
        {
            return;
        }

        poseLandmark.Invoke(webcamTexture, pose);
        debugView.texture = poseLandmark.inputTex;

        landmarkResult = poseLandmark.GetResult(useLandmarkFilter);
        {
            // Apply webcam rotation to draw landmarks correctly
            Matrix4x4 mtx = WebCamUtil.GetMatrix(-webcamTexture.videoRotationAngle, false, webcamTexture.videoVerticallyMirrored);
            for (int i = 0; i < landmarkResult.joints.Length; i++)
            {
                landmarkResult.joints[i] = mtx.MultiplyPoint3x4(landmarkResult.joints[i]);
            }
        }

        RectTransformationCalculator.ApplyToRectTransform(poseLandmark.CropMatrix, croppedFrame.rectTransform);
    }
Exemplo n.º 3
0
        protected override Matrix4x4 CalcCropMatrix(ref PoseDetect.Result pose, ref TextureResizer.ResizeOptions options)
        {
            float rotation = CalcRotationDegree(pose.keypoints[0], pose.keypoints[1]);
            var   rect     = AlignmentPointsToRect(pose.keypoints[0], pose.keypoints[1]);

            return(RectTransformationCalculator.CalcMatrix(new RectTransformationCalculator.Options()
            {
                rect = rect,
                rotationDegree = rotation,
                shift = PoseShift,
                scale = PoseScale,
                cameraRotationDegree = -options.rotationDegree,
                mirrorHorizontal = options.mirrorHorizontal,
                mirrorVertiacal = options.mirrorVertical,
            }));
        }