public BatchClassificationDialog(ref Klu klu, ref TrainingDataSet dataSet, ProcessOptions processOptions)
        {
            InitializeComponent();

            _BackgroundWorker = new BackgroundWorker();
            _BackgroundWorker.WorkerReportsProgress = true;
            _BackgroundWorker.WorkerSupportsCancellation = true;
            _BackgroundWorker.DoWork += new DoWorkEventHandler(DoWork);
            _BackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(RunWorkerCompleted);
            _BackgroundWorker.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged);        

            BrowseButton.IsEnabled = true;
            CancelButton.IsEnabled = false;
            ClassifyButton.IsEnabled = false;

            _DataSet = dataSet;
            _SelectedFiles = new ArrayList();
            _ProcessOptions = processOptions;
            // We want the images to be as less distorded as possible, so we disable all the overlays.

            _ProcessOptions.DrawAnthropometricPoints = 0;
            _ProcessOptions.DrawDetectionTime = 0;
            _ProcessOptions.DrawFaceRectangle = 0;
            _ProcessOptions.DrawSearchRectangles = 0;
            _ProcessOptions.DrawFeaturePoints = 0;
            
            _KLU = klu;
            _FFP = new FaceFeaturePoints();
            _TempBitmap = new System.Drawing.Bitmap(10, 10);

            ExpressionsComboBox.ItemsSource = _DataSet.Expression;
            ClassifyButton.Content = "Classify";
        }
        public BatchClassification(ref Klu klu, ref TrainingDataSet dataSet, ProcessOptions processOptions)
        {
            InitializeComponent();

            _DataSet = dataSet;
            _SelectedFiles = new ArrayList();
            _ProcessOptions = processOptions;
            // We want the images to be as less distorded as possible, so we disable all the overlays.

            _ProcessOptions.DrawAnthropometricPoints = 0;
            _ProcessOptions.DrawDetectionTime = 0;
            _ProcessOptions.DrawFaceRectangle = 0;
            _ProcessOptions.DrawSearchRectangles = 0;
            _ProcessOptions.DrawFeaturePoints = 0;
            
            _KLU = klu;
            _FFP = new FaceFeaturePoints();
            _TempBitmap = new System.Drawing.Bitmap(10, 10);

            ExpressionsComboBox.ItemsSource = _DataSet.Expression;
            ClassifyButton.Content = "Classify";
        }
示例#3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="filepath">Path to the file that shall be processed</param>
 /// <returns>true if successful; otherwise false</returns>
 public bool ProcessStillImage(string filepath, ref ProcessOptions options, ref FaceFeaturePoints ffp)
 {
     return (klu_processStillImage(filepath, options, ffp) == 1);
 }
示例#4
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns>true if successful; otherwise false</returns>
 public bool ProcessCaptureImage(ref ProcessOptions options, ref FaceFeaturePoints ffp)
 {
     return (klu_processCaptureImage(options, ffp) == 1);
 }
示例#5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="filepath">Path to the file that shall be processed</param>
 /// <returns>true if successful; otherwise false</returns>
 public bool ProcessStillImage(string filepath, ref ProcessOptions options, ref FaceFeaturePoints ffp)
 {
     return(klu_processStillImage(filepath, options, ffp) == 1);
 }
示例#6
0
 private static extern int klu_processStillImage(
     [In, MarshalAs(UnmanagedType.LPStr)] string filepath,
     [In, MarshalAs(UnmanagedType.LPStruct)] ProcessOptions processOptions,
     [Out, MarshalAs(UnmanagedType.LPStruct)] FaceFeaturePoints ffp);
示例#7
0
 /// <summary>
 ///
 /// </summary>
 /// <returns>true if successful; otherwise false</returns>
 public bool ProcessCaptureImage(ref ProcessOptions options, ref FaceFeaturePoints ffp)
 {
     return(klu_processCaptureImage(options, ffp) == 1);
 }
示例#8
0
 private static extern int klu_processCaptureImage(
     [In, MarshalAs(UnmanagedType.LPStruct)] ProcessOptions processOptions,
     [Out, MarshalAs(UnmanagedType.LPStruct)] FaceFeaturePoints ffp);
        /// <summary>
        /// The main entry point for this window.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            Console.WriteLine("Loc: " + System.Reflection.Assembly.GetExecutingAssembly().Location);

            try
            {
                _CurrentImagePathIndex = 0;
                _ImagePathArray = new ArrayList();
                _ProcessOptions = new ProcessOptions();
                _FFP = new FaceFeaturePoints();

                _ProcessOptions.DoEyeProcessing = 1;
                _ProcessOptions.DoMouthProcessing = 1;
                _ProcessOptions.DrawAnthropometricPoints = 0;
                _ProcessOptions.DrawSearchRectangles = 0;
                _ProcessOptions.DrawFaceRectangle = 1;
                _ProcessOptions.DrawDetectionTime = 1;
                _ProcessOptions.DrawFeaturePoints = 1;
                _ProcessOptions.DoVisualDebug = 0;

                #region Intialize encapsulated OpenCV subsystem
                _KLU = new Klu();
                _TempBitmap = new System.Drawing.Bitmap(10, 10);

                // Create a Timer with a Normal Priority
                _CaptureTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle, this.Dispatcher);
                
                // Set the callback to just show the time ticking away
                // NOTE: We are using a control so this has to run on 
                // the UI thread
                _CaptureTimer.Tick += new EventHandler(
                    delegate(object s, EventArgs a)
                    {
                        _KLU.ProcessCaptureImage(ref _ProcessOptions, ref _FFP);

                        // Ensure the image (bitmap) we are writing to has the correct dimensions
                        int width = 0, height = 0;
                        _KLU.GetLastProcessedImageDims(ref width, ref height);

                        if (_TempBitmap.Width != width || _TempBitmap.Height != height)
                        {
                            Console.WriteLine("Need to resize the _TempBitmap to " + width + "x" + height);
                            _TempBitmap.Dispose();
                            GC.Collect();
                            _TempBitmap = new System.Drawing.Bitmap(width, height);
                        }

                        _KLU.GetLastProcessedImage(ref _TempBitmap);
                        _KLU.SetWpfImageFromBitmap(ref image1, ref _TempBitmap);
                        //_KLU.SetImageBrushFromBitmap(ref imageBrush, ref _TempBitmap);
                    }
                );
                #endregion

                #region "Connect" to database
                _TAM = new TableAdapterManager();  
                _DataSet = new TrainingDataSet();

                // Load data from SQL database and fill our DataSet
                _TAM.ExpressionTableAdapter = new ExpressionTableAdapter();
                _TAM.TrainingTableAdapter = new TrainingTableAdapter();

                LoadData();
                #endregion
            }            
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }