コード例 #1
0
        private void scan_verso()
        {
            //PassportReader pr = new PassportReader();
            try
            {
                //pr.UseDevice(0, (int)PR_USAGEMODE.PR_UMODE_FULL_CONTROL);
                pr.Capture();


                if (File.Exists(Environment.ExpandEnvironmentVariables("%TEMP%\\") + "verso.jpeg"))
                {
                    File.Delete(Environment.ExpandEnvironmentVariables("%TEMP%\\") + "verso.jpeg");
                }
                pr.SaveImage(0, (int)PR_LIGHT.PR_LIGHT_WHITE, (int)PR_IMAGE_TYPE.PR_IT_DOCUMENT, Environment.ExpandEnvironmentVariables("%TEMP%/") + "verso.jpeg", (int)GX_IMGFILEFORMATS.GX_JPEG);

                prDoc   doc = pr.Recognize(0);
                gxImage img = doc.FieldImage((int)PR_DOCFIELD.PR_DF_VIZ_FACE);
                if (img != null)
                {
                    if (File.Exists(Environment.ExpandEnvironmentVariables("%TEMP%\\") + "PhotoIdentite.jpeg"))
                    {
                        File.Delete(Environment.ExpandEnvironmentVariables("%TEMP%\\") + "PhotoIdentite.jpeg");
                    }
                    img.Save(Environment.ExpandEnvironmentVariables("%TEMP%\\") + "PhotoIdentite.jpeg", (int)GX_IMGFILEFORMATS.GX_JPEG);
                }

                string temp;
                temp = doc.Field((int)PR_DOCFIELD.PR_DF_MRZ1) + doc.Field((int)PR_DOCFIELD.PR_DF_MRZ2) + doc.Field((int)PR_DOCFIELD.PR_DF_MRZ3);
                if (!temp.Equals(""))
                {
                    MRZ = temp;
                }
                else
                {
                    Program.LogFich.Info("[ScannerPiece] pas de piste MRZ sur le verso");
                }
            }
            catch (Exception ex)
            {
                Program.LogFich.Error("[ScannerPiece] n'a pas pu lire le verso du document : " + ex.ToString());
            }
            finally
            {
                //pr.CloseDevice();
                //pr.Close();
                //pr.Dispose();
                //pr = null;
            }
        }
コード例 #2
0
    public int prGetMRZData(System.Collections.IList list)
    {
        try
        {
            if (_doc.IsValid())
            {
                string fieldName, text;
                int    j = "PR_DF_MRZ_".Length;
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                foreach (int i in Enum.GetValues(typeof(PR_DOCFIELD)))
                {
                    if (i <= (int)PR_DOCFIELD.PR_DF_MRZ_FIELDS)
                    {
                        continue;
                    }

                    fieldName = Enum.GetName(typeof(PR_DOCFIELD), i);
                    if (fieldName.StartsWith("PR_DF_MRZ_"))
                    {
                        text = _doc.Field(i);
                        text = text.Replace('<', ' ').Trim();
                        if (!string.IsNullOrEmpty(text))
                        {
                            text = fieldName.Substring(j).Replace('_', ' ') + ": " + text;
                            list.Add(text);
                        }
                    }
                }
            }
        }
        catch (gxException e)
        {
            return(_helper.GetErrorMessage(e, out _errorMessage));
        }
        catch (Exception e)
        {
            _errorMessage = e.Message + " --- prGetMRZData()";
            return(1305);
        }

        return(0);
    }