Exemplo n.º 1
0
        public async Task <string> PerformAnnotation(Texture2D snap)
        {
            textAnnotation = string.Empty;

            if (RescaleInput)
            {
                snap = GenericUtils.Resize(snap, (int)scaleResolution.x, (int)scaleResolution.y);
            }

            _width  = snap.width;
            _height = snap.height;

            // Convert to base64 encoding.
            string _selectedImageData = ImageConvert.Convert(snap);

            AnnotateImage(_selectedImageData, fullFeatureTypes);

            while (annotationCompleted != true)
            {
                await new WaitForEndOfFrame();
            }
            return(textAnnotation);
        }
        public IEnumerator PerformAnnotation(Texture2D snap)
        {
            if (RescaleInput)
            {
                GenericUtils.ScaleTexture(snap, (int)scaleResolution.x, (int)scaleResolution.y);
                Debug.Log("rescaled final: " + snap.width + "," + snap.height);
            }
            //copy image
            temp_image = snap;
            // Convert to base64 encoding.
            string _selectedImageData = ImageConvert.Convert(snap);

            if (MasoutisClient.category == (int)Enums.MasoutisCategories.product)
            {
                // set features types
                var featureTypes = new List <Enumerators.FeatureType>()
                {
                    Enumerators.FeatureType.DOCUMENT_TEXT_DETECTION,
                    Enumerators.FeatureType.OBJECT_LOCALIZATION
                };
                AnnotateImage(_selectedImageData, featureTypes);
            }
            else
            {
                // set features types
                var featureTypes = new List <Enumerators.FeatureType>()
                {
                    Enumerators.FeatureType.DOCUMENT_TEXT_DETECTION
                };
                AnnotateImage(_selectedImageData, featureTypes);
            }

            while (annotationCompleted != true)
            {
                yield return(null);
            }
        }
        private void DetectObjects(Texture2D input_tex)
        {
            text_result = "";

            float startOCRt = Time.realtimeSinceStartup;

            //face and object detection.
            var outputs = _detector.RunInference(input_tex);
            var face    = faceMng.RecognizeFace(input_tex);

            var classNames = outputs.Select(x => x.Key).ToList();
            var classes    = classNames.GroupBy(x => x).ToDictionary(x => x.Key, x => x.ToList().Count);

            foreach (var label in classes)
            {
                if (text_result == String.Empty)
                {
                    text_result = $"{label.Key} {label.Value}";
                }
                else
                {
                    text_result = $"{text_result}, {label.Key} {label.Value}";
                }
            }

            if (face != "Δεν εντοπίστηκε πρόσωπο" && face != "Δεν αναγνωρίστηκε")
            {
                text_result = $"{text_result}, εντοπίστηκε οικείο πρόσωπο με όνομα {face}";
            }

            float endOCRt = Time.realtimeSinceStartup;

            detectionTime = GenericUtils.CalculateTimeDifference(startOCRt, endOCRt);

            inferenceComplete = true;
        }
Exemplo n.º 4
0
        public IEnumerator GetTrailShelfDescription(int category)
        {
            // output message to user.
            yield return(StartCoroutine(voiceSynthesizer.PerformSpeechFromText("Παρακαλώ περιμένετε")));

            float startOCRt = Time.realtimeSinceStartup;

            //ocr annotation.
            yield return(StartCoroutine(OCRAnnotator.PerformAnnotation(camTexture)));

            annotationText = OCRAnnotator.GetAnnotationResults <string>();

            float endOCRt = Time.realtimeSinceStartup;

            OCRtime = CalculateTimeDifference(startOCRt, endOCRt);

            // Perform majority voting
            MajorityVoting majVoting = new MajorityVoting();

            if (!string.IsNullOrEmpty(annotationText))
            {
                float startMajt = Time.realtimeSinceStartup;

                List <string> OCR_List = GenericUtils.SplitStringToList(annotationText);
                yield return(StartCoroutine(majVoting.PerformMajorityVoting(OCR_List)));

                float endMajt = Time.realtimeSinceStartup;
                Majoritytime = CalculateTimeDifference(startMajt, endMajt);

                switch (category)
                {
                case (int)Enums.MasoutisCategories.trail:
                    process_result = majVoting.masoutis_item.category_2;
                    yield return(StartCoroutine(voiceSynthesizer.PerformSpeechFromText("διάδρομος, " + process_result)));

                    break;

                case (int)Enums.MasoutisCategories.shelf:
                    process_result = majVoting.masoutis_item.category_4;
                    yield return(StartCoroutine(voiceSynthesizer.PerformSpeechFromText("ράφι, " + process_result)));

                    break;

                case (int)Enums.MasoutisCategories.other:
                    yield return(StartCoroutine(voiceSynthesizer.PerformSpeechFromText("άλλο, " + "μη αναγνωρίσιμο")));

                    break;

                default:
                    break;
                }
            }
            else
            {
                switch (category)
                {
                case (int)Enums.MasoutisCategories.trail:
                    process_result = "Δεν αναγνωρίστηκαν διαθέσιμες λέξεις";
                    yield return(StartCoroutine(voiceSynthesizer.PerformSpeechFromText("διάδρομος, " + process_result)));

                    break;

                case (int)Enums.MasoutisCategories.shelf:
                    process_result = "Δεν αναγνωρίστηκαν διαθέσιμες λέξεις";
                    yield return(StartCoroutine(voiceSynthesizer.PerformSpeechFromText("ράφι, " + process_result)));

                    break;

                case (int)Enums.MasoutisCategories.other:
                    yield return(StartCoroutine(voiceSynthesizer.PerformSpeechFromText("άλλο, " + "μη αναγνωρίσιμο")));

                    break;

                default:
                    break;
                }
                if (ApplicationView.MajorityFinalText != null)
                {
                    ApplicationView.MajorityFinalText.text = "Δεν αναγνωρίστηκαν διαθέσιμες λέξεις";
                }
                if (ApplicationView.MajorityValidText != null)
                {
                    ApplicationView.MajorityValidText.text = "κενό";
                }

                yield return(StartCoroutine(voiceSynthesizer.PerformSpeechFromText("Δεν αναγνωρίστηκαν διαθέσιμες λέξεις")));
            }
        }
Exemplo n.º 5
0
 private void RescaleTexture(Texture2D snap)
 {
     GenericUtils.ScaleTextureBilinear(snap, (int)scaleResolution.x, (int)scaleResolution.y);
 }
 private void RescaleTexture(Texture2D snap)
 {
     GenericUtils.ScaleTexture(snap, (int)scaleResolution.x, (int)scaleResolution.y);
     Debug.Log(snap.width + " ," + snap.height);
 }