示例#1
0
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.Facemark))
            {
                LogError("owner is not initialized. Add Action \"newFacemark\".");
                return;
            }
            OpenCVForUnity.FaceModule.Facemark wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.Facemark, OpenCVForUnity.FaceModule.Facemark>(owner);

            if (!(image.Value is OpenCVForUnityPlayMakerActions.Mat))
            {
                LogError("image is not initialized. Add Action \"newMat\".");
                return;
            }
            OpenCVForUnity.CoreModule.Mat wrapped_image = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.Mat, OpenCVForUnity.CoreModule.Mat>(image);

            if (!(faces.Value is OpenCVForUnityPlayMakerActions.MatOfRect))
            {
                LogError("faces is not initialized. Add Action \"newMatOfRect\".");
                return;
            }
            OpenCVForUnity.CoreModule.MatOfRect wrapped_faces = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.MatOfRect, OpenCVForUnity.CoreModule.MatOfRect>(faces);

            List <OpenCVForUnity.CoreModule.MatOfPoint2f> wrapped_landmarks = new List <OpenCVForUnity.CoreModule.MatOfPoint2f>();

            OpenCVForUnityPlayMakerActionsUtils.ConvertFsmArrayToList <OpenCVForUnityPlayMakerActions.MatOfPoint2f, OpenCVForUnity.CoreModule.MatOfPoint2f>(landmarks, wrapped_landmarks);

            storeResult.Value = wrapped_owner.fit(wrapped_image, wrapped_faces, wrapped_landmarks);

            OpenCVForUnityPlayMakerActionsUtils.ConvertListToFsmArray <OpenCVForUnity.CoreModule.MatOfPoint2f, OpenCVForUnityPlayMakerActions.MatOfPoint2f>(wrapped_landmarks, landmarks);

            Fsm.Event(storeResult.Value ? trueEvent : falseEvent);
        }