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

            if (!(data.Value is OpenCVForUnityPlayMakerActions.TrainData))
            {
                LogError("data is not initialized. Add Action \"newTrainData\".");
                return;
            }
            OpenCVForUnity.MlModule.TrainData wrapped_data = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.TrainData, OpenCVForUnity.MlModule.TrainData>(data);

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

            storeResult.Value = wrapped_owner.calcError(wrapped_data, test.Value, wrapped_resp);
        }
예제 #2
0
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.TrainData))
            {
                LogError("owner is not initialized. Add Action \"newTrainData\".");
                return;
            }
            OpenCVForUnity.MlModule.TrainData wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.TrainData, OpenCVForUnity.MlModule.TrainData>(owner);

            storeResult.Value = wrapped_owner.getResponseType();
        }
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.TrainData))
            {
                LogError("owner is not initialized. Add Action \"newTrainData\".");
                return;
            }
            OpenCVForUnity.MlModule.TrainData wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.TrainData, OpenCVForUnity.MlModule.TrainData>(owner);

            wrapped_owner.shuffleTrainTest();
        }
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.TrainData))
            {
                LogError("owner is not initialized. Add Action \"newTrainData\".");
                return;
            }
            OpenCVForUnity.MlModule.TrainData wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.TrainData, OpenCVForUnity.MlModule.TrainData>(owner);

            if (!(storeResult.Value is OpenCVForUnityPlayMakerActions.Mat))
            {
                storeResult.Value = new OpenCVForUnityPlayMakerActions.Mat();
            }
            ((OpenCVForUnityPlayMakerActions.Mat)storeResult.Value).wrappedObject = wrapped_owner.getTestSampleIdx();
        }
예제 #5
0
        //
        // C++:  bool cv::ml::StatModel::train(Ptr_TrainData trainData, int flags = 0)
        //

        //javadoc: StatModel::train(trainData, flags)
        public bool train(TrainData trainData, int flags)
        {
            ThrowIfDisposed();
            if (trainData != null)
            {
                trainData.ThrowIfDisposed();
            }
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            bool retVal = ml_StatModel_train_11(nativeObj, trainData.getNativeObjAddr(), flags);

            return(retVal);
#else
            return(false);
#endif
        }
예제 #6
0
        /**
         * Creates training data from in-memory arrays.
         *
         *     param samples matrix of samples. It should have CV_32F type.
         *     param layout see ml::SampleTypes.
         *     param responses matrix of responses. If the responses are scalar, they should be stored as a
         *         single row or as a single column. The matrix should have type CV_32F or CV_32S (in the
         *         former case the responses are considered as ordered by default; in the latter case - as
         *         categorical)
         *     param varIdx vector specifying which variables to use for training. It can be an integer vector
         *         (CV_32S) containing 0-based variable indices or byte vector (CV_8U) containing a mask of
         *         active variables.
         *         vector (CV_32S) containing 0-based sample indices or byte vector (CV_8U) containing a mask
         *         of training samples.
         *         &lt;number_of_variables_in_responses&gt;`, containing types of each input and output variable. See
         *         ml::VariableTypes.
         * return automatically generated
         */
        public static TrainData create(Mat samples, int layout, Mat responses, Mat varIdx)
        {
            if (samples != null)
            {
                samples.ThrowIfDisposed();
            }
            if (responses != null)
            {
                responses.ThrowIfDisposed();
            }
            if (varIdx != null)
            {
                varIdx.ThrowIfDisposed();
            }

            return(TrainData.__fromPtr__(ml_TrainData_create_13(samples.nativeObj, layout, responses.nativeObj, varIdx.nativeObj)));
        }
예제 #7
0
        //javadoc: TrainData::create(samples, layout, responses)
        public static TrainData create(Mat samples, int layout, Mat responses)
        {
            if (samples != null)
            {
                samples.ThrowIfDisposed();
            }
            if (responses != null)
            {
                responses.ThrowIfDisposed();
            }
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            TrainData retVal = TrainData.__fromPtr__(ml_TrainData_create_14(samples.nativeObj, layout, responses.nativeObj));

            return(retVal);
#else
            return(null);
#endif
        }
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.TrainData))
            {
                LogError("owner is not initialized. Add Action \"newTrainData\".");
                return;
            }
            OpenCVForUnity.MlModule.TrainData wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.TrainData, OpenCVForUnity.MlModule.TrainData>(owner);

            if (!(ratio.Value is OpenCVForUnityPlayMakerActions.Double))
            {
                LogError("ratio is not initialized. Add Action \"newDouble\".");
                return;
            }
            System.Double wrapped_ratio = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.Double, System.Double>(ratio);

            wrapped_owner.setTrainTestSplitRatio(wrapped_ratio);
        }
예제 #9
0
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.TrainData))
            {
                LogError("owner is not initialized. Add Action \"newTrainData\".");
                return;
            }
            OpenCVForUnity.MlModule.TrainData wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.TrainData, OpenCVForUnity.MlModule.TrainData>(owner);

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

            wrapped_owner.getValues(vi.Value, wrapped_sidx, values.Value);
        }
예제 #10
0
        //
        // C++:  float cv::ml::StatModel::calcError(Ptr_TrainData data, bool test, Mat& resp)
        //

        //javadoc: StatModel::calcError(data, test, resp)
        public float calcError(TrainData data, bool test, Mat resp)
        {
            ThrowIfDisposed();
            if (data != null)
            {
                data.ThrowIfDisposed();
            }
            if (resp != null)
            {
                resp.ThrowIfDisposed();
            }
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            float retVal = ml_StatModel_calcError_10(nativeObj, data.getNativeObjAddr(), test, resp.nativeObj);

            return(retVal);
#else
            return(-1);
#endif
        }
예제 #11
0
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.StatModel))
            {
                LogError("owner is not initialized. Add Action \"newStatModel\".");
                return;
            }
            OpenCVForUnity.MlModule.StatModel wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.StatModel, OpenCVForUnity.MlModule.StatModel>(owner);

            if (!(trainData.Value is OpenCVForUnityPlayMakerActions.TrainData))
            {
                LogError("trainData is not initialized. Add Action \"newTrainData\".");
                return;
            }
            OpenCVForUnity.MlModule.TrainData wrapped_trainData = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.TrainData, OpenCVForUnity.MlModule.TrainData>(trainData);

            storeResult.Value = wrapped_owner.train(wrapped_trainData, flags.Value);

            Fsm.Event(storeResult.Value ? trueEvent : falseEvent);
        }
예제 #12
0
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.TrainData))
            {
                LogError("owner is not initialized. Add Action \"newTrainData\".");
                return;
            }
            OpenCVForUnity.MlModule.TrainData wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.TrainData, OpenCVForUnity.MlModule.TrainData>(owner);

            string[]      string_names  = names.stringValues;
            List <string> wrapped_names = new List <string>(string_names);

            wrapped_owner.getNames(wrapped_names);

            for (int i = 0; i < wrapped_names.Count; i++)
            {
                names.Set(i, (string)wrapped_names[i]);
            }
            names.SaveChanges();
        }
 public TrainData(OpenCVForUnity.MlModule.TrainData nativeObj) : base(nativeObj)
 {
 }