Пример #1
0
 private void ProcessTestNotFacesButton_Click(object sender, EventArgs e)
 {
     if (!TestNotFacePrefixTextBox.IsEmpty("Test not face prefix,"))
     {
         ResetProgress(testNotFaceFileCount);
         var prefix     = TestNotFacePrefixTextBox.Text;
         var outputName = "testDataNotFace_" + testNotFaceFileCount + "_records" + ".csv";
         ProcessDirAsync(dirTestNotFaceBmp, outputName, ImageType.NotFace, true, prefix, "D6", testNonFacesStartIndex, testNonFacesEndIndex);
     }
 }
Пример #2
0
        private async void ProcessBothTestButton_Click(object sender, EventArgs e)
        {
            if (!TestNotFacePrefixTextBox.IsEmpty("Test not face prefix,") || !TestFacePrefixTextBox.IsEmpty("Test face prefix,"))
            {
                var totalFiles = testFaceFileCount + testNotFaceFileCount;
                ResetProgress(totalFiles);
                var prefix  = TestFacePrefixTextBox.Text;
                var prefix2 = TestNotFacePrefixTextBox.Text;

                Form1.Instance.ClearOutput();
                Form1.Instance.SetCurrentStatus("Processing...");

                var cancelTokenSource = new CancellationTokenSource();
                cancelTokenSources.Add(cancelTokenSource);
                var token = cancelTokenSource.Token;

                Directory.CreateDirectory(dirEvaluationDataSet);
                string outputFile = dirEvaluationDataSet + "testDataBoth_" + totalFiles + "_records" + ".csv";
                using (File.Create(outputFile)) { };

                try {
                    Task taskTestFace = Task.Factory.StartNew(() => Work(dirTestFaceBmp, outputFile, ImageType.Face, true, prefix, "D4",
                                                                         testFacesStartIndex, testFacesEndIndex), token);
                    await Task.WhenAll(taskTestFace);

                    Task taskTestNotFace = Task.Factory.StartNew(() => Work(dirTestNotFaceBmp, outputFile, ImageType.NotFace, true, prefix2, "D6",
                                                                            testNonFacesStartIndex, testNonFacesEndIndex), token);
                    await Task.WhenAll(taskTestNotFace);

                    Form1.Instance.SetCurrentStatus("Finished!");
                } catch (OperationCanceledException) {
                    Form1.Instance.SetCurrentStatus("Stopped!");
                } finally {
                    SetControlsEnabledState(true);
                    cancelTokenSources.Remove(cancelTokenSource);
                }
            }
        }