Пример #1
0
        //javadoc: SVM::trainAuto(samples, layout, responses, kFold, Cgrid, gammaGrid)
        public bool trainAuto(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid)
        {
            ThrowIfDisposed();
            if (samples != null)
            {
                samples.ThrowIfDisposed();
            }
            if (responses != null)
            {
                responses.ThrowIfDisposed();
            }
            if (Cgrid != null)
            {
                Cgrid.ThrowIfDisposed();
            }
            if (gammaGrid != null)
            {
                gammaGrid.ThrowIfDisposed();
            }
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            bool retVal = ml_SVM_trainAuto_15(nativeObj, samples.nativeObj, layout, responses.nativeObj, kFold, Cgrid.getNativeObjAddr(), gammaGrid.getNativeObjAddr());

            return(retVal);
#else
            return(false);
#endif
        }
Пример #2
0
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.SVM))
            {
                LogError("owner is not initialized. Add Action \"newSVM\".");
                return;
            }
            OpenCVForUnity.MlModule.SVM wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.SVM, OpenCVForUnity.MlModule.SVM>(owner);

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

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

            if (!(Cgrid.Value is OpenCVForUnityPlayMakerActions.ParamGrid))
            {
                LogError("Cgrid is not initialized. Add Action \"newParamGrid\".");
                return;
            }
            OpenCVForUnity.MlModule.ParamGrid wrapped_Cgrid = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.ParamGrid, OpenCVForUnity.MlModule.ParamGrid>(Cgrid);

            storeResult.Value = wrapped_owner.trainAuto(wrapped_samples, layout.Value, wrapped_responses, kFold.Value, wrapped_Cgrid);

            Fsm.Event(storeResult.Value ? trueEvent : falseEvent);
        }
Пример #3
0
        /**
         * Trains an %SVM with optimal parameters
         *
         *     param samples training samples
         *     param layout See ml::SampleTypes.
         *     param responses vector of responses associated with the training samples.
         *     param kFold Cross-validation parameter. The training set is divided into kFold subsets. One
         *         subset is used to test the model, the others form the train set. So, the %SVM algorithm is
         *     param Cgrid grid for C
         *     param gammaGrid grid for gamma
         *     param pGrid grid for p
         *         balanced cross-validation subsets that is proportions between classes in subsets are close
         *         to such proportion in the whole train dataset.
         *
         *     The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
         *     nu, coef0, degree. Parameters are considered optimal when the cross-validation
         *     estimate of the test set error is minimal.
         *
         *     This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
         *     offers rudimentary parameter options.
         *
         *     This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
         *     regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
         *     the usual %SVM with parameters specified in params is executed.
         * return automatically generated
         */
        public bool trainAuto(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid)
        {
            ThrowIfDisposed();
            if (samples != null)
            {
                samples.ThrowIfDisposed();
            }
            if (responses != null)
            {
                responses.ThrowIfDisposed();
            }
            if (Cgrid != null)
            {
                Cgrid.ThrowIfDisposed();
            }
            if (gammaGrid != null)
            {
                gammaGrid.ThrowIfDisposed();
            }
            if (pGrid != null)
            {
                pGrid.ThrowIfDisposed();
            }

            return(ml_SVM_trainAuto_14(nativeObj, samples.nativeObj, layout, responses.nativeObj, kFold, Cgrid.getNativeObjAddr(), gammaGrid.getNativeObjAddr(), pGrid.getNativeObjAddr()));
        }
Пример #4
0
        //
        // C++: static Ptr_ParamGrid cv::ml::SVM::getDefaultGridPtr(int param_id)
        //

        //javadoc: SVM::getDefaultGridPtr(param_id)
        public static ParamGrid getDefaultGridPtr(int param_id)
        {
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            ParamGrid retVal = ParamGrid.__fromPtr__(ml_SVM_getDefaultGridPtr_10(param_id));

            return(retVal);
#else
            return(null);
#endif
        }
Пример #5
0
        //javadoc: ParamGrid::create()
        public static ParamGrid create()
        {
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            ParamGrid retVal = ParamGrid.__fromPtr__(ml_ParamGrid_create_13());

            return(retVal);
#else
            return(null);
#endif
        }
Пример #6
0
        //
        // C++: static Ptr_ParamGrid cv::ml::ParamGrid::create(double minVal = 0., double maxVal = 0., double logstep = 1.)
        //

        //javadoc: ParamGrid::create(minVal, maxVal, logstep)
        public static ParamGrid create(double minVal, double maxVal, double logstep)
        {
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            ParamGrid retVal = ParamGrid.__fromPtr__(ml_ParamGrid_create_10(minVal, maxVal, logstep));

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

            wrapped_owner.set_logStep((float)logStep.Value);
        }
Пример #8
0
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.ParamGrid))
            {
                LogError("owner is not initialized. Add Action \"newParamGrid\".");
                return;
            }
            OpenCVForUnity.MlModule.ParamGrid wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.ParamGrid, OpenCVForUnity.MlModule.ParamGrid>(owner);

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

            if (!(storeResult.Value is OpenCVForUnityPlayMakerActions.Double))
            {
                storeResult.Value = new OpenCVForUnityPlayMakerActions.Double();
            }
            ((OpenCVForUnityPlayMakerActions.Double)storeResult.Value).wrappedObject = wrapped_owner.get_minVal();
        }
Пример #10
0
        void DoProcess()
        {
            if (!(owner.Value is OpenCVForUnityPlayMakerActions.ParamGrid))
            {
                LogError("owner is not initialized. Add Action \"newParamGrid\".");
                return;
            }
            OpenCVForUnity.MlModule.ParamGrid wrapped_owner = OpenCVForUnityPlayMakerActionsUtils.GetWrappedObject <OpenCVForUnityPlayMakerActions.ParamGrid, OpenCVForUnity.MlModule.ParamGrid>(owner);

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

            wrapped_owner.set_minVal(wrapped_minVal);
        }
Пример #11
0
        //
        // C++:  bool cv::ml::SVM::trainAuto(Mat samples, int layout, Mat responses, int kFold = 10, Ptr_ParamGrid Cgrid = SVM::getDefaultGridPtr(SVM::C), Ptr_ParamGrid gammaGrid = SVM::getDefaultGridPtr(SVM::GAMMA), Ptr_ParamGrid pGrid = SVM::getDefaultGridPtr(SVM::P), Ptr_ParamGrid nuGrid = SVM::getDefaultGridPtr(SVM::NU), Ptr_ParamGrid coeffGrid = SVM::getDefaultGridPtr(SVM::COEF), Ptr_ParamGrid degreeGrid = SVM::getDefaultGridPtr(SVM::DEGREE), bool balanced = false)
        //

        //javadoc: SVM::trainAuto(samples, layout, responses, kFold, Cgrid, gammaGrid, pGrid, nuGrid, coeffGrid, degreeGrid, balanced)
        public bool trainAuto(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid, ParamGrid degreeGrid, bool balanced)
        {
            ThrowIfDisposed();
            if (samples != null)
            {
                samples.ThrowIfDisposed();
            }
            if (responses != null)
            {
                responses.ThrowIfDisposed();
            }
            if (Cgrid != null)
            {
                Cgrid.ThrowIfDisposed();
            }
            if (gammaGrid != null)
            {
                gammaGrid.ThrowIfDisposed();
            }
            if (pGrid != null)
            {
                pGrid.ThrowIfDisposed();
            }
            if (nuGrid != null)
            {
                nuGrid.ThrowIfDisposed();
            }
            if (coeffGrid != null)
            {
                coeffGrid.ThrowIfDisposed();
            }
            if (degreeGrid != null)
            {
                degreeGrid.ThrowIfDisposed();
            }
#if ((UNITY_ANDROID || UNITY_IOS || UNITY_WEBGL) && !UNITY_EDITOR) || UNITY_5 || UNITY_5_3_OR_NEWER
            bool retVal = ml_SVM_trainAuto_10(nativeObj, samples.nativeObj, layout, responses.nativeObj, kFold, Cgrid.getNativeObjAddr(), gammaGrid.getNativeObjAddr(), pGrid.getNativeObjAddr(), nuGrid.getNativeObjAddr(), coeffGrid.getNativeObjAddr(), degreeGrid.getNativeObjAddr(), balanced);

            return(retVal);
#else
            return(false);
#endif
        }
Пример #12
0
        //
        // C++:  bool cv::ml::SVM::trainAuto(Mat samples, int layout, Mat responses, int kFold = 10, Ptr_ParamGrid Cgrid = SVM::getDefaultGridPtr(SVM::C), Ptr_ParamGrid gammaGrid = SVM::getDefaultGridPtr(SVM::GAMMA), Ptr_ParamGrid pGrid = SVM::getDefaultGridPtr(SVM::P), Ptr_ParamGrid nuGrid = SVM::getDefaultGridPtr(SVM::NU), Ptr_ParamGrid coeffGrid = SVM::getDefaultGridPtr(SVM::COEF), Ptr_ParamGrid degreeGrid = SVM::getDefaultGridPtr(SVM::DEGREE), bool balanced = false)
        //

        /**
         * Trains an %SVM with optimal parameters
         *
         *     param samples training samples
         *     param layout See ml::SampleTypes.
         *     param responses vector of responses associated with the training samples.
         *     param kFold Cross-validation parameter. The training set is divided into kFold subsets. One
         *         subset is used to test the model, the others form the train set. So, the %SVM algorithm is
         *     param Cgrid grid for C
         *     param gammaGrid grid for gamma
         *     param pGrid grid for p
         *     param nuGrid grid for nu
         *     param coeffGrid grid for coeff
         *     param degreeGrid grid for degree
         *     param balanced If true and the problem is 2-class classification then the method creates more
         *         balanced cross-validation subsets that is proportions between classes in subsets are close
         *         to such proportion in the whole train dataset.
         *
         *     The method trains the %SVM model automatically by choosing the optimal parameters C, gamma, p,
         *     nu, coef0, degree. Parameters are considered optimal when the cross-validation
         *     estimate of the test set error is minimal.
         *
         *     This function only makes use of SVM::getDefaultGrid for parameter optimization and thus only
         *     offers rudimentary parameter options.
         *
         *     This function works for the classification (SVM::C_SVC or SVM::NU_SVC) as well as for the
         *     regression (SVM::EPS_SVR or SVM::NU_SVR). If it is SVM::ONE_CLASS, no optimization is made and
         *     the usual %SVM with parameters specified in params is executed.
         * return automatically generated
         */
        public bool trainAuto(Mat samples, int layout, Mat responses, int kFold, ParamGrid Cgrid, ParamGrid gammaGrid, ParamGrid pGrid, ParamGrid nuGrid, ParamGrid coeffGrid, ParamGrid degreeGrid, bool balanced)
        {
            ThrowIfDisposed();
            if (samples != null)
            {
                samples.ThrowIfDisposed();
            }
            if (responses != null)
            {
                responses.ThrowIfDisposed();
            }
            if (Cgrid != null)
            {
                Cgrid.ThrowIfDisposed();
            }
            if (gammaGrid != null)
            {
                gammaGrid.ThrowIfDisposed();
            }
            if (pGrid != null)
            {
                pGrid.ThrowIfDisposed();
            }
            if (nuGrid != null)
            {
                nuGrid.ThrowIfDisposed();
            }
            if (coeffGrid != null)
            {
                coeffGrid.ThrowIfDisposed();
            }
            if (degreeGrid != null)
            {
                degreeGrid.ThrowIfDisposed();
            }

            return(ml_SVM_trainAuto_10(nativeObj, samples.nativeObj, layout, responses.nativeObj, kFold, Cgrid.getNativeObjAddr(), gammaGrid.getNativeObjAddr(), pGrid.getNativeObjAddr(), nuGrid.getNativeObjAddr(), coeffGrid.getNativeObjAddr(), degreeGrid.getNativeObjAddr(), balanced));
        }
Пример #13
0
 public ParamGrid(OpenCVForUnity.MlModule.ParamGrid nativeObj) : base(nativeObj)
 {
 }
Пример #14
0
 /**
  * Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method
  *
  *     param minVal minimum value of the parameter grid
  * return automatically generated
  */
 public static ParamGrid create(double minVal)
 {
     return(ParamGrid.__fromPtr__(ml_ParamGrid_create_12(minVal)));
 }
Пример #15
0
        //
        // C++: static Ptr_ParamGrid cv::ml::ParamGrid::create(double minVal = 0., double maxVal = 0., double logstep = 1.)
        //

        /**
         * Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method
         *
         *     param minVal minimum value of the parameter grid
         *     param maxVal maximum value of the parameter grid
         *     param logstep Logarithmic step for iterating the statmodel parameter
         * return automatically generated
         */
        public static ParamGrid create(double minVal, double maxVal, double logstep)
        {
            return(ParamGrid.__fromPtr__(ml_ParamGrid_create_10(minVal, maxVal, logstep)));
        }
Пример #16
0
 /**
  * Creates a ParamGrid Ptr that can be given to the %SVM::trainAuto method
  *
  * return automatically generated
  */
 public static ParamGrid create()
 {
     return(ParamGrid.__fromPtr__(ml_ParamGrid_create_13()));
 }
Пример #17
0
        //
        // C++: static Ptr_ParamGrid cv::ml::SVM::getDefaultGridPtr(int param_id)
        //

        /**
         * Generates a grid for %SVM parameters.
         *
         *     param param_id %SVM parameters IDs that must be one of the SVM::ParamTypes. The grid is
         *     generated for the parameter with this ID.
         *
         *     The function generates a grid pointer for the specified parameter of the %SVM algorithm.
         *     The grid may be passed to the function SVM::trainAuto.
         * return automatically generated
         */
        public static ParamGrid getDefaultGridPtr(int param_id)
        {
            return(ParamGrid.__fromPtr__(ml_SVM_getDefaultGridPtr_10(param_id)));
        }