예제 #1
0
        private VisionObject FromPrediction(string fileExtension, Bitmap img, PredictionResult prediction)
        {
            var fileInfo = new FileInfo(string.Format(@"C:\Folder\{0}.{1}", Guid.NewGuid(), fileExtension));
            var boxImg   = GetBoxImage(img, prediction.BoundingBox);
            var imgBytes = GetImageBytes(boxImg, GetFormat(fileExtension));
            var ocr      = _ocrService.DoOcr(fileInfo, imgBytes);
            var result   = new VisionObject()
            {
                Location = new Rectangle()
                {
                    X = 0, Y = 0, Width = boxImg.Width, Height = boxImg.Height
                },
                Probability = prediction.Probability,
                TagName     = prediction.TagName,
                OcrResult   = ocr.Data
            };

            return(result);
        }
예제 #2
0
 private void StackObject(VisionObject obj)
 {
     if (objects.Count > 0)
     {
         float deltaWidth = (obj.DispRect.Width - dispRect.Width) / 2.0f;
         if (deltaWidth > 0.0f)
         {
             dispRect.Inflate(deltaWidth, 0.0f);
         }
         float newX = dispRect.X - (deltaWidth < 0.0f ? deltaWidth : 0.0f);
         float newY = dispRect.Bottom + PADDING;
         obj.PutAt(newX, newY);
         dispRect.Height += obj.DispRect.Height + PADDING;
     }
     else
     {
         dispRect = obj.DispRect;
     }
     objects.Add(obj);
 }
예제 #3
0
    private void GetHighestConfidence(VisionData data)
    {
        float        maxConfidence = 0;
        VisionObject obj           = null;

        if (data != null)
        {
            foreach (var vobj in data.objects)
            {
                if (vobj.confidence > maxConfidence)
                {
                    maxConfidence = vobj.confidence;
                    obj           = vobj;
                }
            }
            if (obj != null)
            {
                int    midX      = (obj.rectangle.x + obj.rectangle.w) / 2;
                int    midY      = (obj.rectangle.y + obj.rectangle.h) / 2;
                String objString = obj.obj;
                StartCoroutine(audioManager.playWord(midX, midY, objString));
            }
        }
    }
예제 #4
0
 private void StackObject(VisionObject obj)
 {
     if (objects.Count > 0)
     {
         float deltaWidth = (obj.DispRect.Width - dispRect.Width) / 2.0f;
         if (deltaWidth > 0.0f)
             dispRect.Inflate(deltaWidth, 0.0f);
         float newX = dispRect.X - (deltaWidth < 0.0f ? deltaWidth : 0.0f);
         float newY = dispRect.Bottom + PADDING;
         obj.PutAt(newX, newY);
         dispRect.Height += obj.DispRect.Height + PADDING;
     }
     else
     {
         dispRect = obj.DispRect;
     }
     objects.Add(obj);
 }