Пример #1
0
        /// <summary>
        /// 単体の特徴量構造体を配列に直す  要検討
        /// </summary>
        /// <param name="feature"></param>
        /// <param name="value_array"></param>
        private void SetFeatureToArray(FaceFeature.FeatureValue feature, ref double[] value_array)
        {
            int idx = 0;

            value_array[idx++] = (feature.LeftEyeValueL);
            value_array[idx++] = (feature.LeftEyeValueR);
            value_array[idx++] = (feature.RightEyeValueL);
            value_array[idx++] = (feature.RightEyeValueR);
            value_array[idx++] = (feature.NoseLValueL);
            value_array[idx++] = (feature.NoseLValueR);
            value_array[idx++] = (feature.MouthLValueL);
            value_array[idx++] = (feature.MouthLValueR);
        }
Пример #2
0
        //SVM判定
        public int SVMPredict(FaceFeature.FeatureValue feature)
        {
            double[] feature_array = new double[2];
            SetFeatureToArray(feature, ref feature_array);
            CvMat dataMat = new CvMat(1, 2, MatrixType.F32C1, feature_array, true);

            //学習ファイルを読み込んでいなかったらロード
            if (this.LoadFlag == false)
            {
                svm.Load(@"SvmLearning.xml");
                this.LoadFlag = true;
            }

            return((int)this.svm.Predict(dataMat));
        }
Пример #3
0
        //SVM判定
        public int SVMPredict(FaceFeature.FeatureValue feature)
        {
            //学習ファイルを読み込んでいなかったらロード
            if (this.LoadFlag == false)
            {
                this.libSVM_model = SVM.LoadModel(@"model_FaceFeature.xml");
                this.LoadFlag     = true;
            }

            //スケーリングファイルを読み込む あれば
            if (this.LoadScaleFlag == false && JudgeGUII.APPSetting.NORMALIZE_USE)
            {
                this.LoadScaleFlag = ReadScaleFile(@"out/normalize_scale.csv");
            }

            double[] feature_array = new double[FEATURE_COUNT];
            int      answer        = 0;

            {
                SetFeatureToArray(feature, ref feature_array);
                //ここでスケーリングのデータを読み込んでいたら使う
                if (this.LoadScaleFlag == true && JudgeGUII.APPSetting.NORMALIZE_USE)
                {
                    execNormalize(ref feature_array);
                }

                //問題を作成
                SVMNode[] node_array = new SVMNode[FEATURE_COUNT];

                for (int i = 0; i < FEATURE_COUNT; i++)
                {
                    node_array[i] = new SVMNode(i + 1, feature_array[i]);
                }

                answer = (int)SVM.Predict(libSVM_model, node_array);
                return(answer);
            }
        }