예제 #1
0
        public string scanner_piece()
        {
            prDoc doc;

            try
            {
                //if (!pr.IsCalibrated((int)PR_WINDOW_ID.PR_OW_DEFAULT))
                //    pr.Calibrate((int)PR_WINDOW_ID.PR_OW_DEFAULT);

                pr.Capture();

                /*if (pr.TestDocument((int)PR_WINDOW_ID.PR_OW_DEFAULT) == (int)PR_TESTDOC.PR_TD_IN)
                 * {
                 *  MessageBox.Show("OK");
                 *  pr.Capture();
                 * }
                 * else
                 * {
                 *  MessageBox.Show("PAS OK");
                 *  pr.CloseDevice();
                 *  pr.Close();
                 *  return "";
                 * }*/
            }
            catch (Exception ex)
            {
                MessageBox.Show("Impossible de se connecter au scanner de pièces d'identité");
                Program.LogFich.Error("[ScannerPiece] Impossible de se connecter au scanner de pièces d'identité");
                Program.LogFich.Error(ex.ToString());

                //pr.CloseDevice();
                //pr.Close();
                return("");
            }

            try
            {
                if (File.Exists(Environment.ExpandEnvironmentVariables("%TEMP%\\") + "recto.jpeg"))
                {
                    File.Delete(Environment.ExpandEnvironmentVariables("%TEMP%\\") + "recto.jpeg");
                }

                doc = pr.Recognize(0);

                pr.SaveImage(0, (int)PR_LIGHT.PR_LIGHT_WHITE, (int)PR_IMAGE_TYPE.PR_IT_DOCUMENT, Environment.ExpandEnvironmentVariables("%TEMP%\\") + "recto.jpeg", (int)GX_IMGFILEFORMATS.GX_JPEG);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erreur : " + ex.ToString());
                Program.LogFich.Error("[ScannerPiece] Erreur : " + ex.ToString());
                //pr.CloseDevice();
                //pr.Close();
                return("");
            }

            try
            {
                //pr.SelfTest((int)PR_SELFTEST_ELEMENTS.PRV_ST_LIGHT_SWITCH);


                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);
                    img.Dispose();
                }

                MRZ = 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 (MRZ.Equals(""))
                {
                    Program.LogFich.Info("[ScannerPiece] pas de piste MRZ sur le recto");
                }

                /*if (MessageBox.Show("Pour Scanner le verso, tournez la pièce et cliquer sur Oui.", "Scan Verso", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
                 * {
                 *  pr.CloseDevice();
                 *  //pr.Close();
                 *  scan_verso();
                 * }*/


                if (this.MRZ.Equals("") && visiteurID.Equals(""))
                {
                    MessageBox.Show("Le Document n'a pas de piste MRZ");
                    Program.LogFich.Info("[ScannerPiece] Le Document n'a pas de piste MRZ");
                }

                return(MRZ);
            }
            catch (Exception ex)
            {
                Program.LogFich.Error("[ScannerPiece] n'a pas pu lire le recto du document : " + ex.ToString());
                return("");
            }
            finally
            {
                if (pr != null)
                {
                    pr.ResetDocument();
                    //pr.CloseDevice();
                    //pr.Close();
                    //pr.Dispose();
                }
            }
        }
예제 #2
0
    public int fpsGetFingersImages(int handAndFingerMask, bool saveFingerAsFile)
    {
        try
        {
            if (_arrayOfBMP != null) { _arrayOfBMP.Clear(); _arrayOfBMP = null; }
            if (_arrayOfWSQ != null) { _arrayOfWSQ.Clear(); _arrayOfWSQ = null; }

            /* Search Finger */
            int reqid, stat;

            /* Clears internal stored finger buffers */
            _fps.ResetFingerList();

            /* Starts an asynchronous capture process
            // params: time in usec, quality in per-thousand, mode of live scan, fingerlist
            //
            // The finger list has the format 0hhh 0000 iiii mmmm rrrr llll tttt ssss
            //	h - scan object: 001 left hand, 010 right hand, 011 same fingers of both hands
            //	i - index finger	|
            //	m - middle finger	|
            //	r - ring finger		|--> value of FPS_PRESENCE   FPS_AVAILABLE = 3
            //	l - little finger	|
            //	t - left thumb		|
            //	s - right thumb		|
            */

            int color = (int)FPS_STATUS_LED_COLOR.FPS_SLC_OFF;
            int index = 0;
            int middle = 0;
            int ring = 0;
            int little = 0;
            string wsqIndexFileName = String.Empty;
            string wsqMiddleFileName = String.Empty;
            string wsqRingFileName = String.Empty;
            string wsqLittleFileName = String.Empty;

            _fps.SetStatusLed(0xff, color); // off
            color = (int)FPS_STATUS_LED_COLOR.FPS_SLC_GREEN;

            int fingerMask = 0x00;
            switch (handAndFingerMask & 0xff000000)
            {
                case 0x10000000:    //0x10333300    left hand
                case 0x20000000:    //0x20333300    right hand
                    fingerMask |= (handAndFingerMask & 0x00300000) != 0 ? 0x08 : 0x00;
                    fingerMask |= (handAndFingerMask & 0x00030000) != 0 ? 0x04 : 0x00;
                    fingerMask |= (handAndFingerMask & 0x00003000) != 0 ? 0x02 : 0x00;
                    fingerMask |= (handAndFingerMask & 0x00000300) != 0 ? 0x01 : 0x00;
                    break;
                case 0x30000000:    //0x20000033    thumbs
                    fingerMask |= (handAndFingerMask & 0x00000030) != 0 ? 0x04 : 0x00;
                    fingerMask |= (handAndFingerMask & 0x00000003) != 0 ? 0x02 : 0x00;
                    break;
            }

            int lampMask = fingerMask;
            switch (handAndFingerMask & 0xff000000)
            {
                case 0x10000000:    //0x10333300  left hand
                    index = (int)FPS_POSITION.FPS_POS_LEFT_INDEX;
                    middle = (int)FPS_POSITION.FPS_POS_LEFT_MIDDLE;
                    ring = (int)FPS_POSITION.FPS_POS_LEFT_RING;
                    little = (int)FPS_POSITION.FPS_POS_LEFT_LITTLE;
                    wsqIndexFileName = "lindex.wsq";
                    wsqMiddleFileName = "lmiddle.wsq";
                    wsqRingFileName = "lring.wsq";
                    wsqLittleFileName = "llittle.wsq";
                    lampMask = 0x80;
                    lampMask |= (fingerMask & 0x00000001) != 0 ? 0x08 : 0x00;
                    lampMask |= (fingerMask & 0x00000002) != 0 ? 0x04 : 0x00;
                    lampMask |= (fingerMask & 0x00000004) != 0 ? 0x02 : 0x00;
                    lampMask |= (fingerMask & 0x00000008) != 0 ? 0x01 : 0x00;
                    break;
                case 0x20000000:    //0x20333300
                    index = (int)FPS_POSITION.FPS_POS_RIGHT_INDEX;
                    middle = (int)FPS_POSITION.FPS_POS_RIGHT_MIDDLE;
                    ring = (int)FPS_POSITION.FPS_POS_RIGHT_RING;
                    little = (int)FPS_POSITION.FPS_POS_RIGHT_LITTLE;
                    wsqIndexFileName = "rindex.wsq";
                    wsqMiddleFileName = "rmiddle.wsq";
                    wsqRingFileName = "rring.wsq";
                    wsqLittleFileName = "rlittle.wsq";
                    lampMask |= 0x40;
                    break;
                case 0x30000000:    //0x30000033
                    middle = (int)FPS_POSITION.FPS_POS_LEFT_THUMB;
                    ring = (int)FPS_POSITION.FPS_POS_RIGHT_THUMB;
                    wsqMiddleFileName = "lthumb.wsq";
                    wsqRingFileName = "rthumb.wsq";
                    lampMask |= 0x20;
                    break;
            }

            /* Turning the display leds depending on the mask */
            _fps.SetStatusLed(lampMask, color);

            //reqid = _fps.CaptureStart(100, 100, (int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, 0x10333300);
            reqid = _fps.CaptureStart(3000, 7000, (int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, handAndFingerMask);

            for (stat = 0; stat < 100; )
            {
                /* Test if better images are captured or capture has accomplished */
                stat = _fps.CaptureStatus(reqid);

                _helper.Wait(100);
            }

            /* Closing the capture sequence */
            _fps.CaptureWait(reqid);

            color = (int)FPS_STATUS_LED_COLOR.FPS_SLC_OFF;
            _fps.SetStatusLed(0xff, color); // off

            /* Save individual finger images */
            gxImage img;
            gxVariant var = null;
            int mask = 0x10;

            _arrayOfBMP = new ArrayList();
            _arrayOfWSQ = new ArrayList();

            for (int i = 0; i < 4; i++)
            {
                mask >>= 1;
                bool valid = true;
                switch (fingerMask & mask)
                {
                    case 0x08:
                        try
                        {
                            var = _fps.GetImage((int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, index, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER);
                            if (saveFingerAsFile)
                                _fps.SaveImage(0, index, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER, wsqIndexFileName, (int)GX_IMGFILEFORMATS.GX_WSQ);
                        }
                        catch
                        {
                            valid = false;
                            if (saveFingerAsFile)
                                File.Delete(wsqIndexFileName);
                        }
                        break;
                    case 0x04:
                        try
                        {
                            var = _fps.GetImage((int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, middle, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER);
                            if (saveFingerAsFile)
                                _fps.SaveImage(0, middle, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER, wsqMiddleFileName, (int)GX_IMGFILEFORMATS.GX_WSQ);
                        }
                        catch
                        {
                            valid = false;
                            if (saveFingerAsFile)
                                File.Delete(wsqMiddleFileName);
                        }
                        break;
                    case 0x02:
                        try
                        {
                            var = _fps.GetImage((int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, ring, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER);
                            if (saveFingerAsFile)
                                _fps.SaveImage(0, ring, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER, wsqRingFileName, (int)GX_IMGFILEFORMATS.GX_WSQ);
                        }
                        catch
                        {
                            valid = false;
                            if (saveFingerAsFile)
                                File.Delete(wsqRingFileName);
                        }
                        break;
                    case 0x01:
                        try
                        {
                            var = _fps.GetImage((int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, little, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER);
                            if (saveFingerAsFile)
                                _fps.SaveImage(0, little, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER, wsqLittleFileName, (int)GX_IMGFILEFORMATS.GX_WSQ);
                        }
                        catch
                        {
                            valid = false;
                            if (saveFingerAsFile)
                                File.Delete(wsqLittleFileName);
                        }
                        break;
                    default:
                        _arrayOfBMP.Add(new Byte[] { new Byte() });
                        _arrayOfWSQ.Add(new WsqImage());
        //                        _arrayOfWSQ.Add(new Byte[] { new Byte() });
                        continue;
                }

                if (valid)
                {
                    img = new gxImage();
                    gxVariant vtest = new gxVariant();
                    img.FromVariant(var);

                    WsqImage im = new WsqImage();
                    im.Content = img.SaveToMem((int)GX_IMGFILEFORMATS.GX_WSQ);
                    //im.Content = img.SaveToMem((int)GX_IMGFILEFORMATS.GX_BMP);
                    im.XRes = img.xres() / (10000 / 254);
                    im.YRes = img.yres() / (10000 / 254);
                    im.XSize = img.xsize();
                    im.YSize = img.ysize();
                    im.PixelFormat = img.format();
                    _arrayOfWSQ.Add(im);

                    _arrayOfBMP.Add(img.SaveToMem((int)GX_IMGFILEFORMATS.GX_BMP));
                    //_arrayOfWSQ.Add(img.SaveToMem((int)GX_IMGFILEFORMATS.GX_WSQ));
                    img.Dispose();
                }
                else
                {
                    //list.Add(new Byte[] { new Byte() });
                    _arrayOfBMP.Add(null);
                    _arrayOfWSQ.Add(null);
                }

                if (var != null)
                    var.Dispose();
            }
        }
        catch (gxException e)
        {
            return _helper.GetErrorMessage(e, out _errorMessage);
        }
        catch (Exception e)
        {
            _errorMessage = e.Message + " --- fpsGetFingersImages()";
            return 1305;
        }

        return 0;
    }
예제 #3
0
    public int fpsGetFingersImages(int handAndFingerMask, bool saveFingerAsFile)
    {
        try
        {
            if (_arrayOfBMP != null)
            {
                _arrayOfBMP.Clear(); _arrayOfBMP = null;
            }
            if (_arrayOfWSQ != null)
            {
                _arrayOfWSQ.Clear(); _arrayOfWSQ = null;
            }

            /* Search Finger */
            int reqid, stat;

            /* Clears internal stored finger buffers */
            _fps.ResetFingerList();


            /* Starts an asynchronous capture process
             * // params: time in usec, quality in per-thousand, mode of live scan, fingerlist
             * //
             * // The finger list has the format 0hhh 0000 iiii mmmm rrrr llll tttt ssss
             * //	h - scan object: 001 left hand, 010 right hand, 011 same fingers of both hands
             * //	i - index finger	|
             * //	m - middle finger	|
             * //	r - ring finger		|--> value of FPS_PRESENCE   FPS_AVAILABLE = 3
             * //	l - little finger	|
             * //	t - left thumb		|
             * //	s - right thumb		|
             */

            int    color             = (int)FPS_STATUS_LED_COLOR.FPS_SLC_OFF;
            int    index             = 0;
            int    middle            = 0;
            int    ring              = 0;
            int    little            = 0;
            string wsqIndexFileName  = String.Empty;
            string wsqMiddleFileName = String.Empty;
            string wsqRingFileName   = String.Empty;
            string wsqLittleFileName = String.Empty;

            _fps.SetStatusLed(0xff, color); // off
            color = (int)FPS_STATUS_LED_COLOR.FPS_SLC_GREEN;

            int fingerMask = 0x00;
            switch (handAndFingerMask & 0xff000000)
            {
            case 0x10000000:        //0x10333300    left hand
            case 0x20000000:        //0x20333300    right hand
                fingerMask |= (handAndFingerMask & 0x00300000) != 0 ? 0x08 : 0x00;
                fingerMask |= (handAndFingerMask & 0x00030000) != 0 ? 0x04 : 0x00;
                fingerMask |= (handAndFingerMask & 0x00003000) != 0 ? 0x02 : 0x00;
                fingerMask |= (handAndFingerMask & 0x00000300) != 0 ? 0x01 : 0x00;
                break;

            case 0x30000000:        //0x20000033    thumbs
                fingerMask |= (handAndFingerMask & 0x00000030) != 0 ? 0x04 : 0x00;
                fingerMask |= (handAndFingerMask & 0x00000003) != 0 ? 0x02 : 0x00;
                break;
            }

            int lampMask = fingerMask;
            switch (handAndFingerMask & 0xff000000)
            {
            case 0x10000000:        //0x10333300  left hand
                index             = (int)FPS_POSITION.FPS_POS_LEFT_INDEX;
                middle            = (int)FPS_POSITION.FPS_POS_LEFT_MIDDLE;
                ring              = (int)FPS_POSITION.FPS_POS_LEFT_RING;
                little            = (int)FPS_POSITION.FPS_POS_LEFT_LITTLE;
                wsqIndexFileName  = "lindex.wsq";
                wsqMiddleFileName = "lmiddle.wsq";
                wsqRingFileName   = "lring.wsq";
                wsqLittleFileName = "llittle.wsq";
                lampMask          = 0x80;
                lampMask         |= (fingerMask & 0x00000001) != 0 ? 0x08 : 0x00;
                lampMask         |= (fingerMask & 0x00000002) != 0 ? 0x04 : 0x00;
                lampMask         |= (fingerMask & 0x00000004) != 0 ? 0x02 : 0x00;
                lampMask         |= (fingerMask & 0x00000008) != 0 ? 0x01 : 0x00;
                break;

            case 0x20000000:        //0x20333300
                index             = (int)FPS_POSITION.FPS_POS_RIGHT_INDEX;
                middle            = (int)FPS_POSITION.FPS_POS_RIGHT_MIDDLE;
                ring              = (int)FPS_POSITION.FPS_POS_RIGHT_RING;
                little            = (int)FPS_POSITION.FPS_POS_RIGHT_LITTLE;
                wsqIndexFileName  = "rindex.wsq";
                wsqMiddleFileName = "rmiddle.wsq";
                wsqRingFileName   = "rring.wsq";
                wsqLittleFileName = "rlittle.wsq";
                lampMask         |= 0x40;
                break;

            case 0x30000000:        //0x30000033
                middle            = (int)FPS_POSITION.FPS_POS_LEFT_THUMB;
                ring              = (int)FPS_POSITION.FPS_POS_RIGHT_THUMB;
                wsqMiddleFileName = "lthumb.wsq";
                wsqRingFileName   = "rthumb.wsq";
                lampMask         |= 0x20;
                break;
            }

            /* Turning the display leds depending on the mask */
            _fps.SetStatusLed(lampMask, color);

            //reqid = _fps.CaptureStart(100, 100, (int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, 0x10333300);
            reqid = _fps.CaptureStart(3000, 7000, (int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, handAndFingerMask);

            for (stat = 0; stat < 100;)
            {
                /* Test if better images are captured or capture has accomplished */
                stat = _fps.CaptureStatus(reqid);

                _helper.Wait(100);
            }

            /* Closing the capture sequence */
            _fps.CaptureWait(reqid);

            color = (int)FPS_STATUS_LED_COLOR.FPS_SLC_OFF;
            _fps.SetStatusLed(0xff, color); // off

            /* Save individual finger images */
            gxImage   img;
            gxVariant var  = null;
            int       mask = 0x10;

            _arrayOfBMP = new ArrayList();
            _arrayOfWSQ = new ArrayList();

            for (int i = 0; i < 4; i++)
            {
                mask >>= 1;
                bool valid = true;
                switch (fingerMask & mask)
                {
                case 0x08:
                    try
                    {
                        var = _fps.GetImage((int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, index, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER);
                        if (saveFingerAsFile)
                        {
                            _fps.SaveImage(0, index, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER, wsqIndexFileName, (int)GX_IMGFILEFORMATS.GX_WSQ);
                        }
                    }
                    catch
                    {
                        valid = false;
                        if (saveFingerAsFile)
                        {
                            File.Delete(wsqIndexFileName);
                        }
                    }
                    break;

                case 0x04:
                    try
                    {
                        var = _fps.GetImage((int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, middle, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER);
                        if (saveFingerAsFile)
                        {
                            _fps.SaveImage(0, middle, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER, wsqMiddleFileName, (int)GX_IMGFILEFORMATS.GX_WSQ);
                        }
                    }
                    catch
                    {
                        valid = false;
                        if (saveFingerAsFile)
                        {
                            File.Delete(wsqMiddleFileName);
                        }
                    }
                    break;

                case 0x02:
                    try
                    {
                        var = _fps.GetImage((int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, ring, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER);
                        if (saveFingerAsFile)
                        {
                            _fps.SaveImage(0, ring, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER, wsqRingFileName, (int)GX_IMGFILEFORMATS.GX_WSQ);
                        }
                    }
                    catch
                    {
                        valid = false;
                        if (saveFingerAsFile)
                        {
                            File.Delete(wsqRingFileName);
                        }
                    }
                    break;

                case 0x01:
                    try
                    {
                        var = _fps.GetImage((int)FPS_IMPRESSION_TYPE.FPS_SCAN_LIVE, little, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER);
                        if (saveFingerAsFile)
                        {
                            _fps.SaveImage(0, little, (int)FPS_IMAGE_TYPE.FPS_IT_FINGER, wsqLittleFileName, (int)GX_IMGFILEFORMATS.GX_WSQ);
                        }
                    }
                    catch
                    {
                        valid = false;
                        if (saveFingerAsFile)
                        {
                            File.Delete(wsqLittleFileName);
                        }
                    }
                    break;

                default:
                    _arrayOfBMP.Add(new Byte[] { new Byte() });
                    _arrayOfWSQ.Add(new WsqImage());
//                        _arrayOfWSQ.Add(new Byte[] { new Byte() });
                    continue;
                }

                if (valid)
                {
                    img = new gxImage();
                    gxVariant vtest = new gxVariant();
                    img.FromVariant(var);

                    WsqImage im = new WsqImage();
                    im.Content = img.SaveToMem((int)GX_IMGFILEFORMATS.GX_WSQ);
                    //im.Content = img.SaveToMem((int)GX_IMGFILEFORMATS.GX_BMP);
                    im.XRes        = img.xres() / (10000 / 254);
                    im.YRes        = img.yres() / (10000 / 254);
                    im.XSize       = img.xsize();
                    im.YSize       = img.ysize();
                    im.PixelFormat = img.format();
                    _arrayOfWSQ.Add(im);

                    _arrayOfBMP.Add(img.SaveToMem((int)GX_IMGFILEFORMATS.GX_BMP));
                    //_arrayOfWSQ.Add(img.SaveToMem((int)GX_IMGFILEFORMATS.GX_WSQ));
                    img.Dispose();
                }
                else
                {
                    //list.Add(new Byte[] { new Byte() });
                    _arrayOfBMP.Add(null);
                    _arrayOfWSQ.Add(null);
                }

                if (var != null)
                {
                    var.Dispose();
                }
            }
        }
        catch (gxException e)
        {
            return(_helper.GetErrorMessage(e, out _errorMessage));
        }
        catch (Exception e)
        {
            _errorMessage = e.Message + " --- fpsGetFingersImages()";
            return(1305);
        }

        return(0);
    }