public FormManualTrain(Form1 frm1)
        {
            InitializeComponent();
            browseImage = new OpenFileDialog();

            _form1 = frm1;

            eigenRecog = new Classifier_Train();
            face = new HaarCascade("haarcascade_frontalface_default.xml");
            eyeWithGlass = new CascadeClassifier("haarcascade_eye_tree_eyeglasses.xml");
            mydb = new DBConn();
            minEye = new Size(10, 10);
            maxEye = new Size(225, 225);
            font = new MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX, 0.5d, 0.5d);
            if (File.ReadAllText("setting.txt") != null)
            {
                folderPath = File.ReadAllText("setting.txt");
            }
            else
            {
                FolderBrowserDialog b = new FolderBrowserDialog();
                b.Description = "Please select your installation path";
                DialogResult r = b.ShowDialog();
                if (r == DialogResult.OK) // Test result.
                {
                    folderPath = b.SelectedPath;
                    Console.WriteLine(folderPath);
                    File.WriteAllText(@"setting.txt", folderPath);
                    MessageBox.Show("Path is at " + folderPath);
                }
            }
        }
        private bool LoadTrainingData()
        {
            mydb = new DBConn();
            imagelabel = mydb.getLabelNumList().ToArray();
            imageStringlabel = mydb.getLabelList().ToArray();
            trainingImages = mydb.getTrainedImageList();
            Itrainingimage = trainingImages;
            if (mydb.getImageCount() > 0)
            {

                if (trainingImages.Length != 0)
                {
                    f_recognize = new FisherFaceRecognizer(0, 123.0);
                    f_recognize.Train(Itrainingimage, imagelabel);
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }      
            
            
        }
 public FormManageData(Form1 frm1,Classifier_Train cls)
 {
     InitializeComponent();
     db = new DBConn();
     _form1 = frm1;
     FillData();
     eigenRecog = cls;
     browseImage = new OpenFileDialog();
 }
 public TestRecog()
 {
     mydb = new DBConn();
     totalImage = mydb.getImageCount();
     trainImageArr = mydb.getTrainedImageList();
     diffFaceList = new List<Image<Gray, byte>>();
     AvgFace = getAVGface(trainImageArr);
     diffFaceArr = getDiffFace();
 }
        public FormTrain(Form1 frm1)
        {
            InitializeComponent();
            _form1 = frm1;

            eigenRecog = new Classifier_Train();
            face = new HaarCascade("haarcascade_frontalface_default.xml");
            eyeWithGlass = new CascadeClassifier("haarcascade_eye_tree_eyeglasses.xml");
            mydb = new DBConn();
            minEye = new Size(10, 10);
            maxEye = new Size(225, 225);
            font = new MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX, 0.5d, 0.5d);
            
            captureT = new Capture();
            Application.Idle += new EventHandler(runningCamera);
            
        }
 public FormLab()
 {
     InitializeComponent();
     db = new DBConn();
 }
        private bool LoadTrainingData()
        {
            mydb = new DBConn();
            allname = mydb.getLabelList();           
            trainingImages = mydb.getTrainedImageList();
            int[] temp = Enumerable.Range(0,(allname.Count)).ToArray();
            if (mydb.getImageCount() > 0)
            {

                if (trainingImages.Length != 0)
                {
                    //set round and ...
                    //termCrit = new MCvTermCriteria(mydb.getImageCount(), 0.001);
                    //Eigen face recognizer
                    recognizer = new FisherFaceRecognizer(0,3200);//4000
                    recognizer.Train(trainingImages, temp);
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                return false;
            }
        }
        public Form1()
        {
            InitializeComponent();
            
            face = new HaarCascade("haarcascade_frontalface_default.xml");           
            eyeWithGlass = new CascadeClassifier("haarcascade_eye_tree_eyeglasses.xml");

            mydb = new DBConn();
            maxImageCount = (int)Math.Sqrt(mydb.getImageCount());
            if (maxImageCount % 2 == 0)
            {
                maxImageCount--;
                if(maxImageCount > 15){
                    maxImageCount = 15;
                }
            }
            else
            {
                if (maxImageCount > 15)
                {
                    maxImageCount = 15;
                }
            }
            progressBar1.Maximum = maxImageCount;
            recogNameResult = new List<string>();
            recogDistanceResult = new List<double>();

            minEye = new Size(10, 10);
            maxEye = new Size(225, 225);
            
            font = new MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX, 0.4d, 0.4d);
            fontbig = new MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX, 0.6d, 0.6d);
            fontverybig = new MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX, 0.8d, 0.8d); 

            //log record
            DateTime now = DateTime.Now;
            logName = now.ToString();
            logName = logName.Replace("/", "").Replace(":", "").Replace(" ", "");
            label2.Text = "Idle";
            if(File.Exists("setting.txt")){
                
                folderPath = File.ReadAllText("setting.txt");
            }
            else
            {
                FolderBrowserDialog b = new FolderBrowserDialog();
                b.Description = "Please select your installation path";
                DialogResult r = b.ShowDialog();
                if (r == DialogResult.OK) // Test result.
                {
                    folderPath = b.SelectedPath;
                    Console.WriteLine(folderPath);
                    File.WriteAllText(@"setting.txt", folderPath);
                    MessageBox.Show("Path is at " + folderPath);
                }
            }
            pL[0] = new Point(x0, y0);
            pL[1] = new Point(x0, y1);
            pL[2] = new Point(x1, y1);
            pR[0] = new Point(x3, y0);
            pR[1] = new Point(x3, y1);
            pR[2] = new Point(x2, y1);
            
            eigenRecog = new Classifier_Train();

                
            
        }
 private bool LoadTrainingData()
 {
     mydb = new DBConn();
     allname = mydb.getAllImageID();
     string[] allname_st = allname.Select(x => x.ToString()).ToArray();
     trainingImages = mydb.getTrainedImageList();
     
     //trainingImages = mydb.getRawTrainedImageList();  
         if (mydb.getImageCount() > 0)
         {
             
             if (trainingImages.Length != 0)
             {
                 //set round and ...
                 //termCrit = new MCvTermCriteria(mydb.getImageCount(), 0.001);
                 termCrit = new MCvTermCriteria(5000, 0.0001);
                  //Eigen face recognizer
                 recognizer = new EigenObjectRecognizer(trainingImages, allname_st, maxRecognizeTreshold, ref termCrit);
                 
                 return true;
             }
             else
             {
                 return false;
             }                    
         }
         else
         {
             return false;
         }           
 }
        public Form1()
        {
            InitializeComponent();
            
            face = new HaarCascade("haarcascade_frontalface_default.xml");
            calcface = new HaarCascade("haarcascade_frontalface_default.xml");
            eyeWithGlass = new CascadeClassifier("haarcascade_eye_tree_eyeglasses.xml");
            nose = new CascadeClassifier("haarcascade_mcs_nose.xml");
            mouth = new CascadeClassifier("haarcascade_mcs_mouth.xml");

            mydb = new DBConn();

            recogNameResult = new List<string>();
            recogDistanceResult = new List<double>();
            minEye = new Size(10, 10);
            maxEye = new Size(225, 225);
            minNose = new Size(10, 10);
            maxNose = new Size(225, 225);
            minMouth = new Size(10, 10);
            maxMouth = new Size(225, 225);
            font = new MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX, 0.5d, 0.5d);    

            //log record
            DateTime now = DateTime.Now;
            logName = now.ToString();
            logName = logName.Replace("/", "").Replace(":", "").Replace(" ", "");      
        }