コード例 #1
0
        private void processNextFile()
        {
            _CurrentImagePathIndex++;

            // Start infront if we reach the end
            if (_CurrentImagePathIndex >= _ImagePathArray.Count)
            {
                _CurrentImagePathIndex = 0;
            }

            if (_CurrentImagePathIndex < _ImagePathArray.Count)
            {
                _KLU.ProcessStillImage((string)_ImagePathArray[_CurrentImagePathIndex], ref _ProcessOptions, ref _FFP);

                int width = 0, height = 0;
                _KLU.GetLastProcessedImageDims(ref width, ref height);

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

                _KLU.GetLastProcessedImage(ref _TempBitmap);
                //_KLU.SetImageBrushFromBitmap(ref imageBrush, ref _TempBitmap);
                _KLU.SetWpfImageFromBitmap(ref image1, ref _TempBitmap);
            }
        }
コード例 #2
0
        /// <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);
            }
        }