Esempio n. 1
0
        private void timerCapture_Tick(object sender, EventArgs e)
        {
            string path = _classifyMode ? _savePath : $@"{_savePath}\{DateTime.Now:yyyyMMddHHmmss.fff}.jpg";

            //_bmp.Save(path);
            SaveResizedBitmap(path, 0.5f);

            if (_classifyMode)
            {
                System.Threading.Tasks.Task.Run(() =>
                {
                    // predict the webcam image.
                    MLContext mlContext  = new MLContext(seed: 1);
                    var predictionResult = Classifier.GetSingleImagePrediction(mlContext, ImageClassification.IO.DataLoader.GetPipeline(mlContext, _pipelineZip), ImageClassification.IO.DataLoader.GetModel(mlContext, _modelZip), _savePath);
                    Classified?.Invoke(this, predictionResult);
                    // overray
                    //_frame.PutText($"{predictionResult.PredictedLabel} {predictionResult.Score:P}", new OpenCvSharp.Point(10, 10), HersheyFonts.HersheyPlain, 10, new Scalar(0), 2);
                });
            }
            _count++;
            Captured?.Invoke(this, new CapturedInfo(_count, path));
        }