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

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

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

            double[] casted_storeResult = wrapped_owner.predict2(wrapped_sample, wrapped_probs);

            if (!storeResult.IsNone)
            {
                if (storeResult.Length != casted_storeResult.Length)
                {
                    storeResult.Resize(casted_storeResult.Length);
                }
                for (int i = 0; i < casted_storeResult.Length; i++)
                {
                    storeResult.Set(i, (float)casted_storeResult[i]);
                }
                storeResult.SaveChanges();
            }
        }
示例#2
0
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.EM))
            {
                LogError("owner is not initialized. Add Action \"newEM\".");
                return;
            }
            OpenCVForUnity.MlModule.EM wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.EM, OpenCVForUnity.MlModule.EM>(owner);

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

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

            if (!(storeResult.Value is OpenCVForUnityPlayMakerActions.DoubleArray))
            {
                storeResult.Value = new OpenCVForUnityPlayMakerActions.DoubleArray();
            }
            ((OpenCVForUnityPlayMakerActions.DoubleArray)storeResult.Value).wrappedObject = wrapped_owner.predict2(wrapped_sample, wrapped_probs);
        }