/// <summary> /// Initialises the GlyphDatabase and the GlyphRecogniser, used /// to detect any Glyphs in a given Bitmap image provided by the device used. /// </summary> /// <param name="windowHandle"></param> public GlyphsInput(String windowName) : base(windowName) { glyphDatabase = new GlyphDatabase(5); recognizer = new GlyphRecognizer(glyphDatabase); imageAvailable = false; }
public GlyphDecoder() { // create glyph database for 5x5 glyphs GlyphDatabase glyphDatabase = new GlyphDatabase(5); try { using (StreamReader sr = new StreamReader("Resources/TagDefinitions.txt")) { String line; do { line = sr.ReadLine(); if (line != null) { var tokens = line.Split(' '); var tagID = tokens[0]; var code = tokens[1]; var matrix = new byte[5, 5]; int i = 0; for (int y = 0; y < 5; y++) { for (int x = 0; x < 5; x++) { matrix[y, x] = byte.Parse(code.Substring(i++, 1)); } } glyphDatabase.Add(new Glyph(tagID, matrix)); } } while (line != null); } _glyphRecognizer = new GlyphRecognizer(glyphDatabase); _glyphRecognizer.MaxNumberOfGlyphsToSearch = GLYPHSTOSEARCHFOR; PropertyChanged += (s, e) => { switch (e.PropertyName) { case MinFramesPropertyName: _glyphTable = new GlyphMetadata[GLYPHCOUNT]; break; } }; } catch (Exception e) { LogFormat(e + e.Message + e.StackTrace); } }
/// <summary> /// Refresh the list displaying available databases of glyphss /// </summary> private void LoadGlyphDatabases5() { const string dbName = "ExampleSize5"; const int glyphSize = 5; // Create glyph. string glyphName1 = "Test1"; byte[,] glyphData1 = new byte[glyphSize, glyphSize] { {0, 0, 0, 0, 0}, {0, 0, 1, 0, 0}, {0, 1, 1, 1, 0}, {0, 1, 0, 0, 0}, {0, 0, 0, 0, 0} }; Glyph testGlyph1 = new Glyph(glyphName1, glyphData1); testGlyph1.UserData = new GlyphVisualizationData(Color.Purple); // Create glyph. string glyphName2 = "Test2"; byte[,] glyphData2 = new byte[glyphSize, glyphSize] { {0, 0, 0, 0, 0}, {0, 1, 0, 1, 0}, {0, 0, 1, 0, 0}, {0, 1, 0, 0, 0}, {0, 0, 0, 0, 0} }; Glyph testGlyph2 = new Glyph(glyphName2, glyphData2); testGlyph2.UserData = new GlyphVisualizationData(Color.Blue); // Create glyph. string glyphName3 = "Test3"; byte[,] glyphData3 = new byte[glyphSize, glyphSize] { {0, 0, 0, 0, 0}, {0, 1, 0, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 1, 1, 0}, {0, 0, 0, 0, 0} }; Glyph testGlyph3 = new Glyph(glyphName3, glyphData3); testGlyph3.UserData = new GlyphVisualizationData(Color.Green); // Create database. GlyphDatabase lGlyphDatabase = new GlyphDatabase(glyphSize); // Add glyph to database. lGlyphDatabase.Add(testGlyph1); lGlyphDatabase.Add(testGlyph2); lGlyphDatabase.Add(testGlyph3); // Add database. this.glyphDatabases.AddGlyphDatabase(dbName, lGlyphDatabase); this.recognizer = new GlyphRecognizer(glyphSize); // set the database to image processor ... this.recognizer.GlyphDatabase = this.glyphDatabases[dbName]; ; }
/// <summary> /// Refresh the list displaying available databases of glyphss /// </summary> private void LoadGlyphDatabases12() { const int glyphSize = 12; // Create glyph. string glyphName4 = "Test4"; byte[,] glyphData4 = new byte[glyphSize, glyphSize] { {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0}, {0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0}, {0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0}, {0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0}, {0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} }; Glyph testGlyph4 = new Glyph(glyphName4, glyphData4); testGlyph4.UserData = new GlyphVisualizationData(Color.Purple); // Create database. const string dbName = "ExampleSize12"; // Create database. GlyphDatabase lGlyphDatabase = new GlyphDatabase(glyphSize); // Add glyph to database. lGlyphDatabase.Add(testGlyph4); // Add database. this.glyphDatabases.AddGlyphDatabase(dbName, lGlyphDatabase); this.recognizer = new GlyphRecognizer(glyphSize); // set the database to image processor ... this.recognizer.GlyphDatabase = this.glyphDatabases[dbName]; }
public GlyphImageProcessor(GlyphDatabase database) { _recognizer = new GlyphRecognizer(database); }
public FindDisplay() { // create glyph database for 5x5 glyphs var glyphDatabase = new GlyphDatabase(5); try { using (var stream = new StreamReader("Resources/TagDefinitions.txt")) { String line; do { line = stream.ReadLine(); if (line != null) { var tokens = line.Split(' '); var tagId = tokens[0]; var code = tokens[1]; var matrix = new byte[5, 5]; var i = 0; for (var y = 0; y < 5; y++) { for (var x = 0; x < 5; x++) { matrix[y, x] = byte.Parse(code.Substring(i++, 1)); } } glyphDatabase.Add(new Glyph(tagId, matrix)); } } while (line != null); } _glyphRecognizer = new GlyphRecognizer(glyphDatabase) { MaxNumberOfGlyphsToSearch = 1 }; _glyphTable = new GlyphMetadata[glyphDatabase.Count]; PropertyChanged += (s, e) => { switch (e.PropertyName) { case MinFramesPropertyName: _glyphTable = new GlyphMetadata[glyphDatabase.Count]; break; } }; } catch (Exception e) { LogFormat(e + e.Message + e.StackTrace); } }
private void initGlyphs() { database = new GlyphDatabase(5); Glyph glyph1 = new Glyph("1 ", new byte[,] { {0, 0, 0, 0, 0}, {0, 0, 1, 1, 0}, {0, 1, 0, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0} }); Glyph glyph2 = new Glyph("2 ", new byte[,] { {0, 0, 0, 0, 0}, {0, 1, 0, 1, 0}, {0, 1, 1, 1, 0}, {0, 0, 1, 0, 0}, {0, 0, 0, 0, 0} }); database.Add(glyph1); database.Add(glyph2); recogniser = new GlyphRecognizer(database); }