public void UnRegistBoundaryPointData(int _key) { if (IsRegistedBoundaryDetector(_key)) { m_dicBoundaryPoints.Remove(_key); m_dicBoundaryPointData.Remove(_key); } if (g_refSelectedDetector != null && g_refSelectedDetector.ID == _key) { g_refSelectedDetector = null; } }
public static void Main() { using (MemoryStream ms = new MemoryStream()) { IMatcher matcher = new FlannMatcher(8, 1); IPlayingFieldDetector surfDetector = new SurfPlayingFieldDetector("../../SURF_Resources", matcher); Image image = Image.FromFile("../../IMG-1ca764be45f572eab4a1f5a40a0bffa5-V.jpg"); image.Save(ms, ImageFormat.Png); byte[] byteArray = ms.ToArray(); byte[] detectedPlayingField = surfDetector.DetectPlayingField(byteArray); IBoundaryDetector boundaryDetector = new BoundaryDetector(); PlayingFieldData boundaries = boundaryDetector.GetBoundaries(detectedPlayingField); IOcrProcessor processor = new TesseractOcrProcessor("C:\\Program Files\\Tesseract-OCR\\tessdata", "eng-wordbrain"); IEnumerable <string> allWords = File.ReadLines("../../../Resources/EnglishWords/words_alpha.txt"); ITrie trie = Trie.BuildTrie(allWords); Console.WriteLine("Character matrix"); List <string> characters = processor.GetCharactersFromImage(boundaries.Characters.CharacterMatrix).ToList(); int matrixSize = (int)Math.Sqrt(boundaries.Characters.CharacterCount); int currentIndex = 0; char?[,] characterMatrix = new char?[matrixSize, matrixSize]; for (int i = 0; i < matrixSize; i++) { for (int j = 0; j < matrixSize; j++) { characterMatrix[i, j] = char.Parse(characters[currentIndex]); currentIndex++; } } Console.WriteLine("Hints"); List <string> hintCharacters = new List <string>(); Hint hint = boundaries.Hints.FirstOrDefault(); Stopwatch sw = new Stopwatch(); sw.Start(); IEnumerable <string> possibleSolutions = GetPossibleSolutionsForHint(trie, characterMatrix, hint); sw.Stop(); Console.WriteLine($"Elapsed while finding first words and sqeezing: {sw.Elapsed}"); } }
public void SelectBoundary(int _index) { if (!IsRegistedBoundaryDetector(_index)) { return; } if (g_refSelectedDetector != null) { g_refSelectedDetector.SetDetectorData_Renewal(_index, m_dicBoundaryPointData[_index]); } else { g_refSelectedDetector = new BoundaryDetector(_index, m_dicBoundaryPointData[_index]); } if (g_refBoundaryRenderer == null) { g_refBoundaryRenderer = new BoundaryRenderer(transform); } g_refBoundaryRenderer.SetBoundaryMesh_Renewal(m_dicBoundaryPointData[_index]); }