コード例 #1
0
 public StringField(string name, OcrString value, bool is_accepted, double confidence) : this(csSmartIdEnginePINVOKE.new_StringField__SWIG_1(name, OcrString.getCPtr(value), is_accepted, confidence), true)
 {
     if (csSmartIdEnginePINVOKE.SWIGPendingException.Pending)
     {
         throw csSmartIdEnginePINVOKE.SWIGPendingException.Retrieve();
     }
 }
コード例 #2
0
        private async void ExecuteBeginOcrCommand(object obj)
        {
            if (SelectedIndex >= 0)
            {
                ProgressOCRVisibility = Visibility.Visible;
                OcrString             = string.Empty;
                OcrString             = await OCRHelper.ScanImageOCR(ImageCollection.ListWriteImages, ProcessPages, SelectedIndex, SelectedLanguage);

                if (OcrString.Contains("Supported image dimensions are between 40 and 2600 pixels."))
                {
                    TextblockForeground.Color = Colors.Red;
                }
                else
                {
                    TextblockForeground.Color = Colors.Black;
                }

                ProgressOCRVisibility = Visibility.Collapsed;
            }
        }
コード例 #3
0
        public OcrString GetRawValue()
        {
            OcrString ret = new OcrString(csSmartIdEnginePINVOKE.StringField_GetRawValue(swigCPtr), false);

            return(ret);
        }
コード例 #4
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(OcrString obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
コード例 #5
0
        /// <summary>
        /// Fonction qui va permettre de trouver la position d'un élément sur l'écran.
        /// </summary>
        /// <param name="textToFind"></param>
        /// <param name="cancellationTokenSource"></param>
        /// <param name="timeOut"></param>
        /// <returns></returns>
        public static async Task <FindResult> FindByOcr(OcrString ocrString, CancellationTokenSource cancellationTokenSource, int timeOut = 20)
        {
            Console.WriteLine(@"[FIND_BY_OCR]");

            return(await Task.Run(() =>
            {
                FindResult result = null;

                for (var i = 0; i < timeOut; i++)
                {
                    if (cancellationTokenSource != null)
                    {
                        if (cancellationTokenSource.IsCancellationRequested)
                        {
                            break;
                        }
                    }


                    var p = new Process();
                    var findByOcrExe = Path.Combine(Environment.CurrentDirectory, @"Resources\find_by_ocr.exe");
                    if (!File.Exists(findByOcrExe))
                    {
                        result = new FindResult($"[ERREUR] : Impossible de trouver {findByOcrExe}");
                        break;
                    }

                    var pi = new ProcessStartInfo(findByOcrExe, ocrString.Data);
                    p.StartInfo = pi;
                    pi.UseShellExecute = false;
                    p.OutputDataReceived += (w, o) =>
                    {
                        if (string.IsNullOrEmpty(o.Data) || o.Data.Trim().Length <= 2 || !o.Data.Contains(";"))
                        {
                            return;
                        }
                        try
                        {
                            var point = o.Data.Trim().Split(';');
                            var x = Convert.ToInt32(point[0].Substring(0, point[0].IndexOf('.') > 0 ? point[0].IndexOf('.') : point[0].Length));
                            var y = Convert.ToInt32(point[1].Substring(0, point[1].IndexOf('.') > 0 ? point[1].IndexOf('.') : point[1].Length));
                            Console.WriteLine($@"[FIND_BY_OCR] : {x}:{y}");
                            result = new FindResult(x, y);
                        }
                        catch (Exception)
                        {
                            // ignored
                        }
                    };
                    p.EnableRaisingEvents = true;
                    pi.RedirectStandardOutput = true;
                    pi.StandardOutputEncoding = Encoding.UTF8;


                    Console.WriteLine($@"Looking for {ocrString.Name} [{i}]");


                    p.Start();
                    p.BeginOutputReadLine();

                    p.WaitForExit();



                    if (result != null && string.IsNullOrEmpty(result.Error))
                    {
                        break;
                    }

                    Thread.Sleep(1000);
                }


                return result;
            }));
        }