Пример #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
        private void ClassifyButton_Click(object sender, RoutedEventArgs e)
        {
            if (_SelectedFiles.Count < 1)
            {
                MessageBox.Show("You must at least pick 1 file to classify. Use the \"Browse\" button to look for image files.", "Request for file selection", MessageBoxButton.OK);
                return;
            }

            // Setup the progress bar
            ProgressBar.IsIndeterminate = false;
            ProgressBar.Maximum         = _SelectedFiles.Count;
            ProgressBar.Minimum         = 0;
            ProgressBar.Value           = 0;

            // Process all the selected images files in another thread.

            int expressionOID = (int)Convert.ToUInt32(ExpressionsComboBox.SelectedValue);

            for (int i = 0; i < _SelectedFiles.Count; i++)
            {
                _KLU.ProcessStillImage((string)_SelectedFiles[i], 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 _TempBitmap to " + width + "x" + height);
                    _TempBitmap.Dispose();
                    GC.Collect();
                    _TempBitmap = new System.Drawing.Bitmap(width, height);
                }

                _KLU.GetLastProcessedImage(ref _TempBitmap);

                // Add the training data to the dataset
                ffp.MainWindow.AddTrainingData(ref _DataSet, ref _FFP, expressionOID, ref _TempBitmap);

                ProgressBar.Value = i + 1;
            }
        }
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            if (worker.CancellationPending)
            {
                e.Cancel = true;
                return;
            }

            int expressionOID = Convert.ToInt32(e.Argument);

            // Process all the selected images files in another thread.

            for (int i = 0; i < _SelectedFiles.Count; i++)
            {
                _KLU.ProcessStillImage((string)_SelectedFiles[i], 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 _TempBitmap to " + width + "x" + height);
                    _TempBitmap.Dispose();
                    GC.Collect();
                    _TempBitmap = new System.Drawing.Bitmap(width, height);
                }

                _KLU.GetLastProcessedImage(ref _TempBitmap);

                // Add the training data to the dataset
                ffp.MainWindow.AddTrainingData(ref _DataSet, ref _FFP, expressionOID, ref _TempBitmap);

                if (i % 10 == 0 || i == (_SelectedFiles.Count - 1))
                {
                    worker.ReportProgress((int)(100 * (float)(i + 1) / (float)_SelectedFiles.Count));
                }
            }
        }