Beispiel #1
0
        private void GenerateObjectsFromArray(object[] array, Enumerators.DataType type)
        {
            if (array == null)
            {
                return;
            }

            AnnotateContentItem newItem;

            foreach (var item in array)
            {
                if (item == null)
                {
                    continue;
                }

                newItem = new AnnotateContentItem(_parentOfContentGroup, item, type);
                _annotateContentItems.Add(newItem);

                if (type == Enumerators.DataType.PAGES)
                {
                    foreach (var block in (item as Page).blocks)
                    {
                        newItem = new AnnotateContentItem(_parentOfContentGroup, block, Enumerators.DataType.BLOCKS);
                        _annotateContentItems.Add(newItem);

                        foreach (var paragraph in block.paragraphs)
                        {
                            newItem = new AnnotateContentItem(_parentOfContentGroup, paragraph, Enumerators.DataType.PARAGRAPH);
                            _annotateContentItems.Add(newItem);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        private void FillContentDataByFeatureType(Enumerators.ResponseDataType type)
        {
            if (_currentVisionResponse == null)
            {
                return;
            }

            ResetContentData();

            _annotateContentItems = new List <AnnotateContentItem>();
            AnnotateContentItem newItem;

            foreach (var response in _currentVisionResponse.responses)
            {
                switch (type)
                {
                case Enumerators.ResponseDataType.LABELS:
                {
                    GenerateObjectsFromArray(response.labelAnnotations, Enumerators.DataType.LABELS);
                }
                break;

                case Enumerators.ResponseDataType.LOGOS:
                {
                    GenerateObjectsFromArray(response.logoAnnotations, Enumerators.DataType.LOGOS);
                }
                break;

                case Enumerators.ResponseDataType.TEXT:
                {
                    GenerateObjectsFromArray(response.textAnnotations, Enumerators.DataType.TEXT);
                }
                break;

                case Enumerators.ResponseDataType.PROPERTIES:
                {
                    if (response.imagePropertiesAnnotation == null)
                    {
                        break;
                    }

                    GenerateObjectsFromArray(response.imagePropertiesAnnotation.dominantColors.colors, Enumerators.DataType.DOMINANT_COLORS);
                }
                break;

                case Enumerators.ResponseDataType.WEB:
                {
                    if (response.webDetection == null)
                    {
                        break;
                    }

                    GenerateObjectsFromArray(response.webDetection.fullMatchingImages, Enumerators.DataType.FULLY_MATCHED_IMAGES);
                    GenerateObjectsFromArray(response.webDetection.pagesWithMatchingImages, Enumerators.DataType.PAGES_WITH_MATHCHED_IMAGES);
                    GenerateObjectsFromArray(response.webDetection.partialMatchingImages, Enumerators.DataType.PARTIALLY_MATCHED_IMAGES);
                    GenerateObjectsFromArray(response.webDetection.visuallySimilarImages, Enumerators.DataType.VISUAL_SIMILAR_IMAGES);
                    GenerateObjectsFromArray(response.webDetection.webEntities, Enumerators.DataType.WEB_ENTITIES);
                }
                break;

                case Enumerators.ResponseDataType.SAFE_SEARCH:
                {
                    if (response.safeSearchAnnotation == null)
                    {
                        break;
                    }

                    newItem = new AnnotateContentItem(_parentOfContentGroup, response.safeSearchAnnotation, Enumerators.DataType.SAFE_SEARCHS);
                    _annotateContentItems.Add(newItem);
                }
                break;

                case Enumerators.ResponseDataType.DOCUMENT:
                {
                    if (response.fullTextAnnotation == null)
                    {
                        break;
                    }

                    GenerateObjectsFromArray(response.fullTextAnnotation.pages, Enumerators.DataType.PAGES);
                }
                break;

                default: break;
                }
            }
        }