/// <summary> /// Constructs a universal recognizer that using the specified /// recognizers and caching enabled or disabled. /// </summary> /// <param name="wireRecognizer">the recognizer to use on wires</param> /// <param name="textRecognizer">the recognizer to use on text</param> /// <param name="gateRecognizer">the recognizer to use on gates</param> /// <param name="cacheInnerRecognizers">True if the individual /// sub-recognizers should cache their results. (NOTE: you typically /// would not want to wrap a UniversalRecognizer in a CachedRecognizer /// since the CachedRecognizer ignores the shape classification when /// retrieving results. So if you did that and changed the shape /// classification, the resulting recognizer may often ignore it.</param> /// <exception cref="ArgumentException.ArgumentException">Thrown if /// the provided recognizers cannot recognize what they are intended /// to (e.g., if the wireRecognizer reports that it cannot recognize /// wires).</exception> public UniversalRecognizer( Recognizer wireRecognizer, Recognizer textRecognizer, Recognizer gateRecognizer, bool cacheInnerRecognizers) { if (wireRecognizer == null) { wireRecognizer = new WireRecognizer(); } if (textRecognizer == null) { textRecognizer = new TextRecognizer(); } if (gateRecognizer == null) { gateRecognizer = ImageRecognizer.Load(AppDomain.CurrentDomain.BaseDirectory + @"SubRecognizers\ImageRecognizer\Image.ir"); } if (!wireRecognizer.canRecognize("Wire")) { throw new ArgumentException("The provided wire recognizer '" + wireRecognizer + "' cannot recognize wires!"); } if (!textRecognizer.canRecognize("Text")) { throw new ArgumentException("The provided text recognizer '" + textRecognizer + "' cannot recognize text!"); } if (!gateRecognizer.canRecognize("Gate")) { throw new ArgumentException("The provided gate recognizer '" + gateRecognizer + "' cannot recognize gates!"); } if (cacheInnerRecognizers) { wireRecognizer = new CachedRecognizer(wireRecognizer); textRecognizer = new CachedRecognizer(textRecognizer); gateRecognizer = new CachedRecognizer(gateRecognizer); } _wireRecognizer = wireRecognizer; _textRecognizer = textRecognizer; _gateRecognizer = gateRecognizer; }
/// <summary> /// Constructs a universal recognizer that using the specified /// recognizers and caching enabled or disabled. /// </summary> /// <param name="wireRecognizer">the recognizer to use on wires</param> /// <param name="textRecognizer">the recognizer to use on text</param> /// <param name="gateRecognizer">the recognizer to use on gates</param> /// <exception cref="ArgumentException.ArgumentException">Thrown if /// the provided recognizers cannot recognize what they are intended /// to (e.g., if the wireRecognizer reports that it cannot recognize /// wires).</exception> public UniversalRecognizer( Recognizer wireRecognizer = null, Recognizer textRecognizer = null, Recognizer gateRecognizer = null) { if (wireRecognizer == null) { wireRecognizer = new WireRecognizer(); } if (textRecognizer == null) { textRecognizer = new TextRecognizer(); } if (gateRecognizer == null) { #if AIR_OFF gateRecognizer = new ImageRecognizer(); #else gateRecognizer = AdaptiveImageRecognizer.LoadDefault(); #endif } if (!wireRecognizer.canRecognize("Wire")) { throw new ArgumentException("The provided wire recognizer '" + wireRecognizer + "' cannot recognize wires!"); } if (!textRecognizer.canRecognize("Text")) { throw new ArgumentException("The provided text recognizer '" + textRecognizer + "' cannot recognize text!"); } if (!gateRecognizer.canRecognize("Gate")) { throw new ArgumentException("The provided gate recognizer '" + gateRecognizer + "' cannot recognize gates!"); } _wireRecognizer = wireRecognizer; _textRecognizer = textRecognizer; _gateRecognizer = gateRecognizer; }