// Path: facerecognitionlibrary/src/main/java/ch/zhaw/facerecognitionlibrary/Helpers/OneToOneMap.java
// public class OneToOneMap<Key, Value> {
//     private Map<Key, Value> keyToVal;
//     private Map<Value, Key> valToKey;
// 
//     public OneToOneMap() {
//         this.keyToVal = new HashMap<>();
//         this.valToKey = new HashMap<>();
//     }
// 
//     public void put(Key k, Value v) {
//         if (!keyToVal.containsKey(k) && !valToKey.containsKey(v)) {
//             keyToVal.put(k, v);
//             valToKey.put(v, k);
//         }
//     }
// 
//     public boolean containsKey(Key k){
//         return keyToVal.containsKey(k);
//     }
// 
//     public Value getValue(Key k){
//         return keyToVal.get(k);
//     }
// 
//     public Key getKey(Value v){
//         return valToKey.get(v);
//     }
// 
//     public int size(){
//         return keyToVal.size();
//     }
// 
//     public Map getKeyToValMap(){
//         return keyToVal;
//     }
// }


import ch.zhaw.facerecognitionlibrary.Helpers.OneToOneMap;
import ch.zhaw.facerecognitionlibrary.Helpers.PreferencesHelper;
import android.content.Context;
import org.opencv.core.Mat;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.List;
import ch.zhaw.facerecognitionlibrary.Helpers.FileHelper;
/* Copyright 2016 Michael Sladoje and Mike Schälchli. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

package ch.zhaw.facerecognitionlibrary.Recognition;





/***************************************************************************************
 *    Title: AndroidLibSvm
 *    Author: yctung
 *    Date: 16.09.2015
 *    Code version: -
 *    Availability: https://github.com/
 *
 ***************************************************************************************/

public class SupportVectorMachine implements Recognition {
    PreferencesHelper preferencesHelper;
    private FileHelper fh;
    private File trainingFile;
    private File predictionFile;
    private File testFile;
    private List<String> trainingList;
    private List<String> testList;
    private OneToOneMap<String, Integer> labelMap;
    private OneToOneMap<String, Integer> labelMapTest;
    private int method;

    public SupportVectorMachine(Context context, int method) {
        preferencesHelper = new PreferencesHelper(context);
        fh = new FileHelper();
        trainingFile = fh.createSvmTrainingFile();
        predictionFile = fh.createSvmPredictionFile();
        testFile = fh.createSvmTestFile();
        trainingList = new ArrayList<>();
        testList = new ArrayList<>();
        labelMap = new OneToOneMap<String, Integer>();
// Path: facerecognitionlibrary/src/main/java/ch/zhaw/facerecognitionlibrary/Helpers/OneToOneMap.java
// public class OneToOneMap<Key, Value> {
//     private Map<Key, Value> keyToVal;
//     private Map<Value, Key> valToKey;
// 
//     public OneToOneMap() {
//         this.keyToVal = new HashMap<>();
//         this.valToKey = new HashMap<>();
//     }
// 
//     public void put(Key k, Value v) {
//         if (!keyToVal.containsKey(k) && !valToKey.containsKey(v)) {
//             keyToVal.put(k, v);
//             valToKey.put(v, k);
//         }
//     }
// 
//     public boolean containsKey(Key k){
//         return keyToVal.containsKey(k);
//     }
// 
//     public Value getValue(Key k){
//         return keyToVal.get(k);
//     }
// 
//     public Key getKey(Value v){
//         return valToKey.get(v);
//     }
// 
//     public int size(){
//         return keyToVal.size();
//     }
// 
//     public Map getKeyToValMap(){
//         return keyToVal;
//     }
// }


// Path: facerecognitionlibrary/src/main/java/ch/zhaw/facerecognitionlibrary/Recognition/SupportVectorMachine.java
import ch.zhaw.facerecognitionlibrary.Helpers.OneToOneMap;
import ch.zhaw.facerecognitionlibrary.Helpers.PreferencesHelper;
import android.content.Context;
import org.opencv.core.Mat;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.List;
import ch.zhaw.facerecognitionlibrary.Helpers.FileHelper;

/* Copyright 2016 Michael Sladoje and Mike Schälchli. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

package ch.zhaw.facerecognitionlibrary.Recognition;





/***************************************************************************************
 *    Title: AndroidLibSvm
 *    Author: yctung
 *    Date: 16.09.2015
 *    Code version: -
 *    Availability: https://github.com/
 *
 ***************************************************************************************/

public class SupportVectorMachine implements Recognition {
    PreferencesHelper preferencesHelper;
    private FileHelper fh;
    private File trainingFile;
    private File predictionFile;
    private File testFile;
    private List<String> trainingList;
    private List<String> testList;
    private OneToOneMap<String, Integer> labelMap;
    private OneToOneMap<String, Integer> labelMapTest;
    private int method;

    public SupportVectorMachine(Context context, int method) {
        preferencesHelper = new PreferencesHelper(context);
        fh = new FileHelper();
        trainingFile = fh.createSvmTrainingFile();
        predictionFile = fh.createSvmPredictionFile();
        testFile = fh.createSvmTestFile();
        trainingList = new ArrayList<>();
        testList = new ArrayList<>();
        labelMap = new OneToOneMap<String, Integer>();
        labelMapTest = new OneToOneMap<String, Integer>();