Example #1
0
        public void Add(VisionResponse res)
        {
            var text  = res.responses[0].FullTextAnnotation.text;
            var split = text.Split('\n');
            var input = TrimMana(split[0]);
            var title = ClosestStringMatch.Find(input, _allCardNames.data);

            Log($"Found {title} as best match for {input}");

            var card = new Card()
            {
                Title = title,
            };

            var existing = _library.Find(title);

            if (existing != null)
            {
                Log($"Duplicate card {card.Title}");
                card.TypeId = existing.TypeId;
            }
            else
            {
                Warn($"New card {card.Title}");
                card.TypeId = Guid.NewGuid();
                _library.AddType(card);
            }

            _library.AddInstance(card.TypeId);
        }
Example #2
0
        private void ProcessResponse(VisionResponse visionRecog)
        {
            if (visionRecog == null)
            {
                //MessageBox.Show("Process Failed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (visionRecog.responses.Count == 0)
            {
                //MessageBox.Show("No text found", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var fullText = visionRecog.responses[0].FullTextAnnotation;

            if (fullText == null)
            {
                Warn("Empty vision response");
                return;
            }

            Add(visionRecog);
        }