コード例 #1
0
 public OcrEngine()
 {
     IncludeTextRegions = true;
     Timeout            = 30000;
     SupportedLanguages = new Dictionary <string, string>();
     if (!RemoteOcr.IsRemote(GetType()) && GetType() != typeof(RemoteOcr) && IsInstalled)
     {
         GetSupportedLanguages();
     }
 }
コード例 #2
0
        public OcrResult Load(OcrImage image, string language)
        {
            try
            {
                OcrResult result = null;

                if (GetType() != typeof(RemoteOcr) && RemoteOcr.IsRemote(GetType()))
                {
                    OcrEngineType targetType = GetType(GetType());
                    RemoteOcr     remoteOcr  = new RemoteOcr(targetType);
                    result = remoteOcr.Load(image, language, language);
                }
                else if (!IsInstalled)
                {
                    return(OcrResult.Create(OcrResultType.NotInstalled));
                }
                else
                {
                    string apiLanguage = language == null ? null : GetSupportedLanguageName(language);
                    if (string.IsNullOrEmpty(apiLanguage))
                    {
                        return(OcrResult.Create(OcrResultType.LanguageNotSupported));
                    }
                    result = Load(image, language, apiLanguage);
                }

                if (result != null && result.Rect == OcrRect.Empty)
                {
                    result.Rect = new OcrRect(0, 0, image.Width, image.Height);
                }

                return(result);
            }
            catch (Exception e)
            {
                return(OcrResult.Create(OcrResultType.Exception, e.ToString()));
            }
        }