예제 #1
0
        public InceptionPage()
            : base()
        {
            _inceptionGraph = new Inception();
            _inceptionGraph.OnDownloadProgressChanged += onDownloadProgressChanged;
            _inceptionGraph.OnDownloadCompleted       += onDownloadCompleted;

            OnImagesLoaded += (sender, image) =>
            {
                try
                {
                    SetMessage("Please wait...");
                    SetImage();


                    Tensor    imageTensor = Emgu.TF.Models.ImageIO.ReadTensorFromImageFile(image[0], 224, 224, 128.0f, 1.0f / 128.0f);
                    Stopwatch watch       = Stopwatch.StartNew();
                    Inception.RecognitionResult result = _inceptionGraph.MostLikely(imageTensor);

                    SetMessage(String.Format("Object is {0} with {1}% probability. Recognized in {2} milliseconds.", result.Label, result.Probability * 100, watch.ElapsedMilliseconds));

                    SetImage(image[0]);
                }
                catch (Exception excpt)
                {
                    String msg = excpt.Message.Replace(System.Environment.NewLine, " ");
                    SetMessage(msg);
                }
            };
        }
예제 #2
0
    private void RecognizeAndUpdateText(Texture2D texture)
    {
        if (!_inceptionGraph.Imported)
        {
            return;
        }
        Tensor imageTensor = ImageIO.ReadTensorFromTexture2D(texture, 224, 224, 128.0f, 1.0f, true);

        Inception.RecognitionResult result = _inceptionGraph.MostLikely(imageTensor);
        _displayMessage = String.Format("Object is {0} with {1}% probability.", result.Label, result.Probability);
    }