示例#1
0
 private void ProcessTestFaceButton_Click(object sender, EventArgs e)
 {
     if (!TestFacePrefixTextBox.IsEmpty("Test face prefix,"))
     {
         ResetProgress(testFaceFileCount);
         var prefix     = TestFacePrefixTextBox.Text;
         var outputName = "testDataFace" + testFaceFileCount + "_records" + ".csv";
         ProcessDirAsync(dirTestFaceBmp, outputName, ImageType.Face, true, prefix, "D4", testFacesStartIndex, testFacesEndIndex);
     }
 }
示例#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);
                }
            }
        }