Ejemplo n.º 1
0
        public static void LumiCaptureProcess(byte[] snapShot24bppPointer, byte[] template1Pointer, ref uint templateSize1, uint width, uint height, LumiSDKWrapper.LumiPreviewCallbackDelegate callbackFunc)
        {
            try
            {
                byte[] snapShot = new byte[width * height]; // Array to hold raw data 8 bpp format

                int spoof = 0;

                _rc = LumiSDKWrapper.LumiCaptureEx(_hHandle, snapShot, template1Pointer, ref templateSize1, ref spoof, callbackFunc);

                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    throw new Exception("ERROR: lumiCaptureProcess rc = " + _rc);
                }
                else
                {
                    _statusMessage += "PASS: lumiCaptureProcess rc = " + _rc + " spoof = " + spoof + "\r\n";
                }

                ConvertRawImageTo24bpp(snapShot24bppPointer, snapShot, snapShot.Length);
            }
            catch (Exception err)
            {
                _statusMessage += "An Error occured: " + err.ToString() + "\r\n";
                //CloseScanner();
                throw err;
            }
            finally { }
        }
Ejemplo n.º 2
0
        public LumiSDKWrapper.LumiStatus EnrollImage(byte[] snapShot, byte[] snapShot24bppPointer, byte[] template1Pointer, ref uint templateSize, uint width, uint height, ref int spoof, LumiSDKWrapper.LumiPresenceDetectCallbackDelegate callbackFunc, ref uint nNFIQ)
        {
            try
            {
                //byte[] snapShot = new byte[width * height]; // Array to hold raw data 8 bpp format

                // Make sure Presence Detection is on.
                // Because we need another definition for LumiSetOption, we call the SetPresenceDetectionMode
                // static method on the object LumiSDKLumiSetOption.  This is because the LumiSDKWrapper
                // has the LumiSetOption defined to take the LumiPresenceDetectCallbackDelegate argument while for
                // setting PD mode, we need it to take an integer pointer argument instead.
                if (m_form.m_bSensorTriggerArmed)
                {
                    LumiSDKLumiSetOption.SetPresenceDetectionMode(_hHandle, LumiSDKWrapper.LUMI_PRES_DET_MODE.LUMI_PD_ON);
                }
                else
                {
                    LumiSDKLumiSetOption.SetPresenceDetectionMode(_hHandle, LumiSDKWrapper.LUMI_PRES_DET_MODE.LUMI_PD_OFF);
                }

                // Set the address of the presence detection callback function
                IntPtr prtDel = Marshal.GetFunctionPointerForDelegate(callbackFunc);
                _rc = LumiSDKWrapper.LumiSetOption(_hHandle, LumiSDKWrapper.LUMI_OPTIONS.LUMI_OPTION_SET_PRESENCE_DET_CALLBACK, prtDel, (uint)IntPtr.Size);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    return(_rc);
                }
                _rc = LumiSDKWrapper.LumiSetDCOptions(_hHandle, m_form.m_debugFolder, 0);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    return(_rc);
                }
                _rc = LumiSDKWrapper.LumiCaptureEx(_hHandle, snapShot, template1Pointer, ref templateSize, ref spoof, null);


                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    return(_rc);
                }
                else
                {
                    _statusMessage += "PASS: lumiCaptureProcess rc = " + _rc + " spoof = " + spoof + "\r\n";
                }

                GetNISTScore(snapShot, ref nNFIQ);


                LumiSDKWrapper.LumiSetOption(_hHandle, LumiSDKWrapper.LUMI_OPTIONS.LUMI_OPTION_SET_PRESENCE_DET_CALLBACK, IntPtr.Zero, (uint)IntPtr.Size); // size of int is 4

                ConvertRawImageTo24bpp(snapShot24bppPointer, snapShot, snapShot.Length);

                return(_rc);
            }
            catch (Exception err)
            {
                _statusMessage += "An Error occured: " + err + "\r\n";
                throw err;
            }
            finally { }
        }
Ejemplo n.º 3
0
        public static void Match(byte[] template1Pointer, ref uint nTemp1Len, byte[] template2Pointer, ref uint nTemp2Len, ref uint score, ref int spoof)
        {
            try
            {
                List <byte[]> templates = new List <byte[]>();
                templates.Add(template1Pointer);
                templates.Add(template2Pointer);
                _rc = LumiSDKWrapper.LumiMatch(_hHandle, (byte [])templates[0], ref nTemp1Len, (byte[])templates[1], ref nTemp2Len, ref score, ref spoof);

                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    throw new Exception("ERROR: lumiMatch rc = " + _rc);
                }
                else
                {
                    _statusMessage += "PASS: lumiMatch rc = " + _rc + "\r\n";
                    _statusMessage += "PASS: Match Score = " + score + "\r\n";
                    _statusMessage += "PASS: Match Spoof Score = " + spoof + " (should be  -1) \r\n";
                }
            }
            catch (Exception err)
            {
                _statusMessage += "An Error occured: " + err.ToString() + "\r\n";
                //CloseScanner();
                throw err;
            }
            finally { }
        }
Ejemplo n.º 4
0
        public static bool ExtractTemplateAvailable()
        {
            try
            {
                LumiSDKWrapper.LUMI_DEVICE_CAPS dCaps = new LumiSDKWrapper.LUMI_DEVICE_CAPS();
                _rc = LumiSDKWrapper.LumiGetDeviceCaps(_hHandle, ref dCaps);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    throw new Exception("FAIL: LumiGetDeviceCaps");
                }

                if ((int)dCaps.bExtract == 0)
                {
                    return(false);
                }

                return(true);
            }
            catch (Exception err)
            {
                _statusMessage += "An Error occured: " + err.ToString() + "\r\n";
                //CloseScanner();
                throw err;
            }
            finally { }
        }
Ejemplo n.º 5
0
        public void GetNISTScore(byte[] pImage, ref uint nNFIQ)
        {
            uint nBPP = 0, nDPI = 0;
            uint nWidth  = 0;
            uint nHeight = 0;

            _rc = LumiSDKWrapper.LumiGetImageParams(_hHandle, ref nWidth, ref nHeight, ref nBPP, ref nDPI);
            LumiInOpAPIWrapper.LumiInOpAPIWrapper.LumiStatus rc;
            rc = LumiInOpAPIWrapper.LumiInOpAPIWrapper.LumiComputeNFIQFromImage(pImage, nWidth, nHeight, nBPP, nDPI, ref nNFIQ);
        }
Ejemplo n.º 6
0
        public void ForceFingerLift()
        {
            LumiSDKWrapper.LumiAcqStatusCallbackDelegate del = _form.AcquStatusCallback;

            LumiSDKWrapper.LUMI_ACQ_STATUS nStatus = LumiSDKWrapper.LUMI_ACQ_STATUS.LUMI_ACQ_BUSY;

            LumiSDKWrapper.LumiStatus rc = LumiSDKWrapper.LumiDetectFinger(_hHandle, ref nStatus, del);

            if (rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
            {
            }
        }
Ejemplo n.º 7
0
 public static void SetConfig(LumiSDKWrapper.LUMI_CONFIG config)
 {
     try
     {
         _rc = LumiSDKWrapper.LumiSetConfig(_hHandle, config);
     }
     catch (Exception err)
     {
         _statusMessage += "An Error occured: " + err.ToString() + "  _rc = " + _rc + "\r\n";
         throw err;
     }
     finally { }
 }
Ejemplo n.º 8
0
 public void CloseScanner()
 {
     try
     {
         _rc = LumiSDKWrapper.LumiClose(_hHandle);
         _rc = LumiSDKWrapper.LumiExit();
     }
     catch (Exception err)
     {
         _statusMessage += "An Error occured: " + err + "  _rc = " + _rc + "\r\n";
         throw err;
     }
     finally { }
 }
Ejemplo n.º 9
0
        public static void LumiCaptureWithPresenceDetectionFeedback(byte[] snapShot24bppPointer, byte[] template1Pointer, ref uint templateSize1, uint width, uint height, LumiSDKWrapper.LumiPresenceDetectCallbackDelegate callbackFunc)
        {
            try
            {
                byte[] snapShot = new byte[width * height]; // Array to hold raw data 8 bpp format

                int spoof = 0;
                // Make sure Presence Detection is on.
                // Because we need another definition for LumiSetOption, we call the SetPresenceDetectionMode
                // static method on the object LumiSDKLumiSetOption.  This is because the LumiSDKWrapper
                // has the LumiSetOption defined to take the LumiPresenceDetectCallbackDelegate argument while for
                // setting PD mode, we need it to take an integer pointer argument instead.
                LumiSDKLumiSetOption.SetPresenceDetectionMode(_hHandle, LumiSDKWrapper.LUMI_PRES_DET_MODE.LUMI_PD_ON);

                // Set the address of the presence detection callback function
                IntPtr prtDel = Marshal.GetFunctionPointerForDelegate(callbackFunc);
                _rc = LumiSDKWrapper.LumiSetOption(_hHandle, LumiSDKWrapper.LUMI_OPTIONS.LUMI_OPTION_SET_PRESENCE_DET_CALLBACK, prtDel, GetIntPtrSz());
                _rc = LumiSDKWrapper.LumiSetDCOptions(_hHandle, "C:/Temp/", 0);
                LumiSDKWrapper.LUMI_PROCESSING_MODE procMode;
                procMode.bExtract = 1;
                procMode.bLatent  = 0;
                procMode.bSpoof   = 1;
                _rc = LumiSDKWrapper.SetProcessingMode(_hHandle, procMode);
                procMode.bExtract = 0;
                _rc = LumiSDKWrapper.GetProcessingMode(_hHandle, ref procMode);
                //_rc = LumiCapture(_hHandle, snapshotPointer, &spoof, null);
                _rc = LumiSDKWrapper.LumiCaptureEx(_hHandle, snapShot, template1Pointer, ref templateSize1, ref spoof, null);

                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    throw new Exception("ERROR: lumiCaptureProcess rc = " + _rc);
                }
                else
                {
                    _statusMessage += "PASS: lumiCaptureProcess rc = " + _rc + " spoof = " + spoof + "\r\n";
                }
                LumiSDKWrapper.LumiSetOption(_hHandle, LumiSDKWrapper.LUMI_OPTIONS.LUMI_OPTION_SET_PRESENCE_DET_CALLBACK, IntPtr.Zero, GetIntPtrSz()); // size of int is 4

                ConvertRawImageTo24bpp(snapShot24bppPointer, snapShot, snapShot.Length);
            }
            catch (Exception err)
            {
                _statusMessage += "An Error occured: " + err.ToString() + "\r\n";
                //CloseScanner();
                throw err;
            }
            finally { }
        }
Ejemplo n.º 10
0
        public void GetWidthAndHeight(ref uint width, ref uint height)
        {
            try
            {
                uint nBPP = 0, nDPI = 0;
                _rc = LumiSDKWrapper.LumiGetImageParams(_hHandle, ref width, ref height, ref nBPP, ref nDPI);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    throw new Exception("FAIL: lumiGetImageSize");
                }

                _statusMessage += "PASS: Image Size = " + width + " X " + height + "\r\n";
            }
            catch (Exception err)
            {
                _statusMessage += "An Error occured: " + err + "\r\n";
                throw err;
            }
            finally { }
        }
Ejemplo n.º 11
0
        ////////////////////////////////////////////////////////////////////////
        // SDKBiometrics functions
        ////////////////////////////////////////////////////////////////////////
        public static void OpenScanner()
        {
            try
            {
                uint nNumDevices = 0;
                _rc = LumiSDKWrapper.LumiQueryNumberDevices(ref nNumDevices, _ipAddress);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    throw new Exception("Failed to query number of devices.  _rc = " + _rc);
                }
                if (nNumDevices == 0)
                {
                    throw new Exception("There are no Lumidigm 1s connected to the PC.\r\nPlease close the application and connect a Lumidigm Sensor.");
                }

                dev = new LumiSDKWrapper.LUMI_DEVICE();

                _rc = LumiSDKWrapper.LumiQueryDevice(0, ref dev);  // Query the first device

                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    throw new Exception("Failed to query scanner.  _rc = " + _rc + "\r\n");
                }
                uint tmpHandle = 0;
                _rc = LumiSDKWrapper.LumiInit(dev.hDevHandle, ref tmpHandle);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    throw new Exception("Failed to init scanner.  _rc = " + _rc + "\r\n");
                }
                _hHandle = tmpHandle;
            }
            catch (Exception err)
            {
                throw err;
            }
            finally { }
        }
Ejemplo n.º 12
0
        public void Run()
        {
            uint width = 0, height = 0;
            int  nSpoof = 0;

            GetWidthAndHeight(ref width, ref height);
            byte[] snapShot24bpp = new byte[width * height * 3]; // multiply by 3 to get 24bppRgb format
            byte[] template1     = new byte[5000];               //array to hold the template
            uint   templateLen1  = 0;
            uint   nMatchScore1  = 0;
            int    nSpoofScore   = 0;

            LumiSDKWrapper.LumiPresenceDetectCallbackDelegate del = m_form.PresenceDetectionCallback;
            m_form.Invoke(m_form.m_DelegateErrorMessage, "Place finger down for verification", m_form.Blue);

            ////////////////////////////
            LumiSDKWrapper.LUMI_PROCESSING_MODE processingMode;
            processingMode.bExtract = 0;
            processingMode.bLatent  = 0;
            processingMode.bSpoof   = 0;
            LumiSDKWrapper.LumiStatus pStatus = LumiSDKWrapper.GetProcessingMode(_hHandle, ref processingMode);
            if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
            {
                m_form.Invoke(m_form.m_DelegateErrorMessage, "Enrollment failed. Unable to Set the Spoof detection mode", m_form.Red);
                return;
            }
            processingMode.bSpoof = m_form.m_bSpoofEnabled ? (byte)1 : (byte)0;

            pStatus = LumiSDKWrapper.SetProcessingMode(_hHandle, processingMode);
            if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
            {
                m_form.Invoke(m_form.m_DelegateErrorMessage, "Enrollment failed. Unable to Set the Spoof detection mode", m_form.Red);
                return;
            }
            //////////////////////////////////

            if (EnrollAndDisplay(snapShot24bpp, template1, ref templateLen1, width, height, ref nSpoof, del) == false)
            {
                m_form.Invoke(m_form.m_VerifyThreadFinished);
                return;
            }

            if (m_form.m_bClosingApp)
            {
                CloseScanner();
                return;
            }

            /*int index;
             * index = m_form.m_currentSubject.fingers.IndexOf(m_form.m_CurrentHotSpot);
             * uint templatelength = (uint)m_form.m_currentSubject.templateLengths[index];
             *
             * LumiSDKWrapper.LumiMatch(_hHandle, template1, ref templateLen1, (byte[])m_form.m_currentSubject.templates[index], ref templatelength, ref nMatchScore1, ref nSpoofScore);
             * if (m_form.m_bSpoofEnabled&&(nSpoof != -1))
             * {
             *  if (nMatchScore1 > m_form.m_MatchThreshold && nSpoof <= m_form.m_SpoofThreshold)
             *  {
             *      m_form.Invoke(m_form.m_DelegateErrorMessage, "Match Score = " + nMatchScore1 + "\nSpoof Score = " + nSpoof + "\nVerification Successful", m_form.Blue);
             *  }
             *
             *  else
             *  {
             *      m_form.Invoke(m_form.m_DelegateErrorMessage, "Match Score = " + nMatchScore1 + "\nSpoof Score = " + nSpoof + "\nVerification Failed", m_form.Red);
             *
             *  }
             * }
             * else
             * {
             *  if (nMatchScore1 > m_form.m_MatchThreshold)
             *  {
             *      m_form.Invoke(m_form.m_DelegateErrorMessage, "Match Score = " + nMatchScore1 + "\nVerification Successful", m_form.Blue);
             *  }
             *
             *  else
             *  {
             *      m_form.Invoke(m_form.m_DelegateErrorMessage, "Match Score = " + nMatchScore1 + "\nVerification Failed", m_form.Red);
             *
             *  }
             * }*/


            m_form.Invoke(m_form.m_VerifyThreadFinished);
        }
Ejemplo n.º 13
0
        public static void TestAPI(ImageFrm form)
        {
            try
            {
                LumiSDKWrapper.LumiStatus _rc;
                StringBuilder             _ipAddress = new StringBuilder("");
                //uint _hHandle = 0;

                form.DisableControls();

                //get sensor type
                switch (dev.SensorType)
                {
                case LumiSDKWrapper.LUMI_SENSOR_TYPE.VENUS:
                    form.AddResults("V30X Initialized\n");
                    break;

                case LumiSDKWrapper.LUMI_SENSOR_TYPE.V31X:
                    form.AddResults("V31X Initialized\n");
                    break;

                case LumiSDKWrapper.LUMI_SENSOR_TYPE.M300:
                    form.AddResults("M30X Initialized\n");
                    break;

                case LumiSDKWrapper.LUMI_SENSOR_TYPE.M31X:
                    form.AddResults("M31X Initialized\n");
                    break;

                case LumiSDKWrapper.LUMI_SENSOR_TYPE.M32X:
                    form.AddResults("M32X Initialized\n");
                    break;

                default:
                    throw new Exception("Unrecognized Sensor Type");
                }

                //get version info
                LumiSDKWrapper.LUMI_VERSION ver = new LumiSDKWrapper.LUMI_VERSION();
                _rc = LumiSDKWrapper.LumiGetVersionInfo(_hHandle, ref ver);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    throw new Exception("Failed to get version info.  _rc = " + _rc + "\r\n");
                }

                form.PrintVersion(ver);

                // GET DEVICECAPS
                LumiSDKWrapper.LUMI_DEVICE_CAPS sysCaps = new LumiSDKWrapper.LUMI_DEVICE_CAPS();
                _rc = LumiSDKWrapper.LumiGetDeviceCaps(_hHandle, ref sysCaps);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    throw new Exception("Failed to get device capabilities.  _rc = " + _rc + "\r\n");
                }
                form.PrintDeviceCaps(sysCaps);
                //set PD callback off
                LumiSDKWrapper.LumiPresenceDetectCallbackDelegate del = new LumiSDKWrapper.LumiPresenceDetectCallbackDelegate(form.PresenceDetectionCallback);
                IntPtr prtDel = Marshal.GetFunctionPointerForDelegate(del);
                _rc = LumiSDKWrapper.LumiSetOption(_hHandle, LumiSDKWrapper.LUMI_OPTIONS.LUMI_OPTION_SET_PRESENCE_DET_CALLBACK, prtDel, GetIntPtrSz());
                //get processing mode
                LumiSDKWrapper.LUMI_PROCESSING_MODE procMode = new LumiSDKWrapper.LUMI_PROCESSING_MODE();
                _rc = LumiSDKWrapper.GetProcessingMode(_hHandle, ref procMode);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK && (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_ERROR_CMD_NOT_SUPPORTED))
                {
                    throw new Exception("Failed to get processing mode.  _rc = " + _rc + "\r\n");
                }
                //set DC options folder
                _rc = LumiSDKWrapper.LumiSetDCOptions(_hHandle, "C:\\BAD_FOLDER\\", 1);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_INVALID_FOLDER)
                {
                    form.AddResults("Didn't recognize bad folder\n");
                }
                //set DC options folder
                _rc = LumiSDKWrapper.LumiSetDCOptions(_hHandle, "C:\\", 1);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    form.AddResults("Didn't set good folder\n");
                }

                //try out V series options
                if (dev.SensorType == LumiSDKWrapper.LUMI_SENSOR_TYPE.VENUS)
                {
                    // SET OPTION - Turn off hearbeat

                    IntPtr pHeartbeat = Marshal.AllocHGlobal(sizeof(int));// int *HeartBeat = new int;
                    Marshal.WriteInt32(pHeartbeat, 1);

                    _rc = LumiSDKWrapper.LumiSetOption(_hHandle, LumiSDKWrapper.LUMI_OPTIONS.LUMI_OPTION_SET_OVERRIDE_HEARTBEAT_DISPLAY, pHeartbeat, sizeof(int));
                    if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                    {
                        throw new Exception("Failed to override heartbeat display.  _rc = " + _rc + "\r\n");
                    }


                    form.AddResults("Flashing LEDs\n");
                    //Turn Red LED ON
                    _rc = LumiSDKWrapper.LumiSetLED(_hHandle, LumiSDKWrapper.LUMI_LED_CONTROL.LUMI_VENUS_RED_ON);
                    if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                    {
                        form.AddResults("Could not set Venus red LED to on\n");
                    }
                    System.Threading.Thread.Sleep(500);

                    //Turn Red LED OFF
                    _rc = LumiSDKWrapper.LumiSetLED(_hHandle, LumiSDKWrapper.LUMI_LED_CONTROL.LUMI_VENUS_RED_OFF);
                    if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                    {
                        form.AddResults("Could not set Venus red LED to off\n");
                    }
                    System.Threading.Thread.Sleep(500);

                    //Turn Green LED ON
                    _rc = LumiSDKWrapper.LumiSetLED(_hHandle, LumiSDKWrapper.LUMI_LED_CONTROL.LUMI_VENUS_GREEN_ON);
                    if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                    {
                        form.AddResults("Could not set Venus green LED to on\n");
                    }
                    System.Threading.Thread.Sleep(500);

                    //Turn GREEN LED OFF
                    _rc = LumiSDKWrapper.LumiSetLED(_hHandle, LumiSDKWrapper.LUMI_LED_CONTROL.LUMI_VENUS_GREEN_OFF);
                    if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                    {
                        form.AddResults("Could not set Venus green LED to off\n");
                    }
                    System.Threading.Thread.Sleep(500);

                    //Turn back on the hearbeat
                    Marshal.WriteInt32(pHeartbeat, 0);
                    _rc = LumiSDKWrapper.LumiSetOption(_hHandle, LumiSDKWrapper.LUMI_OPTIONS.LUMI_OPTION_SET_OVERRIDE_HEARTBEAT_DISPLAY, pHeartbeat, sizeof(int));
                    if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                    {
                        throw new Exception("Failed to override heartbeat display.  _rc = " + _rc + "\r\n");
                    }
                }


                // Set Option – Acq Status Callback
                form.AddResults("Calling LumiSetOption... Acq status callback\n");
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    form.AddResults("Could not set ACQ status callback\n");
                }

                uint nW = 0, nH = 0, nDPI = 0, nBPP = 0, nTemplateLength1 = 0, nTemplateLength2 = 0, nScore = 0;
                int  nSpoof = 0;

                ////Turn off video Mode
                _rc = LumiSDKWrapper.LumiGetImageParams(_hHandle, ref nW, ref nH, ref nBPP, ref nDPI);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    form.AddResults("Could not get image params\n");
                }
                else
                {
                    form.AddResults("Width: " + nW + " Height: " + nH);
                    form.AddResults("\r\nBPP: " + nBPP + " DPI: " + nDPI + "\r\n");
                }

                //Quality Map
                byte[] QualityMap = new byte[nW * nH];
                _rc = LumiSDKWrapper.LumiGetQualityMap(_hHandle, QualityMap);
                if (dev.SensorType == LumiSDKWrapper.LUMI_SENSOR_TYPE.VENUS)
                {
                    // Try to get Quality Map before capture or verify - should return LUMI_STATUS_QUALITY_MAP_NOT_GENERATED
                    if (_rc == LumiSDKWrapper.LumiStatus.LUMI_STATUS_QUALITY_MAP_NOT_GENERATED)
                    {
                        form.AddResults("Could not get quality map. This is expected.\n");
                    }
                }
                else
                {
                    // Try to get Quality Map with Mercury - should return LUMI_STATUS_ERROR_CMD_NOT_SUPPORTED
                    form.AddResults("Non V30x device. Return Code: " + _rc + "\r\n");
                }

                //Capture
                form.AddResults("Place Your Finger\n");
                byte[] pImage     = new byte[nW * nH];
                byte[] pTemplate1 = new byte[5000];
                byte[] pTemplate2 = new byte[5000];

                _rc = LumiSDKWrapper.LumiCapture(_hHandle, pImage, ref nSpoof, null);

                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    form.AddResults("Could not capture\n");
                }
                form.AddResults("Spoof: " + nSpoof + "\n");

                //check sensor health
                _rc = LumiSDKWrapper.LumiSetOption(_hHandle, LumiSDKWrapper.LUMI_OPTIONS.LUMI_OPTION_CHECK_SENSOR_HEALTH, IntPtr.Zero, 0);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    form.AddResults("Could not set option\n");
                }
                // SAVE LAST CAPTURE WITH BAD FOLDER
                form.AddResults("Saving Last Capture with bad folder...\n");
                _rc = LumiSDKWrapper.LumiSaveLastCapture(_hHandle, "User1", 5, 1);
                form.AddResults("Results: " + _rc + "\n"); // Expecting LUMI_STATUS_DC_OPTIONS_NOT_SET to be returned

                // SET DC OPTIONS WITH GOOD FOLDER
                form.AddResults("Saving Last Capture with good folder...\n");
                _rc = LumiSDKWrapper.LumiSetDCOptions(_hHandle, "C:\\", 1);// 1 for true, 0 for false
                form.AddResults("Results: " + _rc + "\n");

                //CaptureEX test for invalid parameter
                form.AddResults("CaptureEX with null parameter...\n");
                _rc = LumiSDKWrapper.LumiCaptureEx(_hHandle, pImage, null, ref nTemplateLength1, ref nSpoof, null);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_INVALID_PARAMETER)
                {
                    form.AddResults("CaptureEX didn't return invalid parameter with a null template\n");
                }

                //And were done!
                form.EnableControls();

                // Capture Ex
                form.AddResults("CaptureEX...\n");
                _rc = LumiSDKWrapper.LumiCaptureEx(_hHandle, pImage, pTemplate1, ref nTemplateLength1, ref nSpoof, null);
                form.AddResults("Results: " + _rc + "\n");
                if ((_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK) && (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_CANCELLED_BY_USER))
                {
                    form.AddResults("Capture failed\n");
                }
                form.AddResults("...Spoof " + nSpoof + "\n");

                //Quality Map
                _rc = LumiSDKWrapper.LumiGetQualityMap(_hHandle, QualityMap);

                if (dev.SensorType == LumiSDKWrapper.LUMI_SENSOR_TYPE.VENUS)
                {
                    // Try to get Quality Map before capture or verify - should return LUMI_STATUS_QUALITY_MAP_NOT_GENERATED
                    if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                    {
                        form.AddResults("Could not get quality map\n");
                    }
                    else
                    {
                        //save Quality map as bitmap
                        int    newSize = QualityMap.Length * 3;
                        byte[] rgb     = new byte[newSize];//24bpp
                        for (int i = 0; i < QualityMap.Length; i++)
                        {
                            rgb[i * 3]     = QualityMap[i];
                            rgb[i * 3 + 1] = QualityMap[i];
                            rgb[i * 3 + 2] = QualityMap[i];
                        }
                        Bitmap     bmp     = new Bitmap((int)nW, (int)nH, PixelFormat.Format24bppRgb);
                        BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, (int)nW, (int)nH), ImageLockMode.WriteOnly, bmp.PixelFormat);
                        IntPtr     ptr     = bmpData.Scan0;
                        Marshal.Copy(rgb, 0, bmpData.Scan0, newSize);
                        bmp.UnlockBits(bmpData);
                        bmp.Save("QualityMap2.bmp");
                    }
                }
                else
                {
                    //should return LUMI_STATUS_ERROR_CMD_NOT_SUPPORTED
                    form.AddResults("Non V30x device. Return Code: " + _rc + "\r\n");
                }

                // save last capture
                form.AddResults("Saving Last Capture with good folder...\n");
                _rc = LumiSDKWrapper.LumiSaveLastCapture(_hHandle, "User1", 5, 1);
                form.AddResults("Results: " + _rc + "\n");

                //capture again
                form.AddResults("CaptureEX...\n");
                _rc = LumiSDKWrapper.LumiCaptureEx(_hHandle, pImage, pTemplate2, ref nTemplateLength2, ref nSpoof, null);
                form.AddResults("Results: " + _rc + "\n");
                if ((_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK) && (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_CANCELLED_BY_USER))
                {
                    form.AddResults("Capture failed\n");
                }
                form.AddResults("...Spoof " + nSpoof + "\n");

                //verify
                form.AddResults("Verify...\n");
                _rc = LumiSDKWrapper.LumiVerify(_hHandle, pTemplate2, nTemplateLength2, ref nSpoof, ref nScore);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    form.AddResults("Verify failed\n");
                }
                else
                {
                    form.AddResults("Verify Complete.  Score " + nScore + ". Spoof " + nSpoof + "\n");
                }

                //match
                form.AddResults("Match...\n");
                _rc = LumiSDKWrapper.LumiMatch(_hHandle, pTemplate1, ref nTemplateLength1, pTemplate2, ref nTemplateLength2, ref nScore, ref nSpoof);
                if (_rc != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    form.AddResults("Match failed\n");
                }
                else
                {
                    form.AddResults("Match Complete.  Score " + nScore + "\n");
                }
                form.AddResults("API Test Complete \n");
            }
            catch (Exception err)
            {
                throw err;
            }
            finally { }
        }
Ejemplo n.º 14
0
        public void Run()
        {
            try
            {
                var sensorid = (Sensor)m_form.SensorList[(int)m_form.m_nSelectedSensorID];
                _hHandle = sensorid.handle;
                uint width = 0, height = 0;
                int  nSpoof = 0;
                GetWidthAndHeight(ref width, ref height);
                byte[] snapShot24bpp = new byte[width * height * 3]; // multiply by 3 to get 24bppRgb format
                byte[] template      = new byte[5000];               //array to hold the template
                uint   templateLen   = 0;
                uint   nNFIQ         = 0;
                // Assign the main form's PresenceDetectionCallback method to the LumiPresenceDetectCallbackDelegate
                LumiSDKWrapper.LumiPresenceDetectCallbackDelegate del = m_form.PresenceDetectionCallback;

                byte[] snapShot = new byte[width * height]; // raw 8 bpp image buffer

                ////////////////////

                if (sensorid.SensorType == LumiSDKWrapper.LUMI_SENSOR_TYPE.M32X)
                {
                    Bitmap     bitmap1    = Resources.CaptureInProgress_M320_resized;
                    BitmapData bmpData    = bitmap1.LockBits(new Rectangle(0, 0, bitmap1.Width, bitmap1.Height), ImageLockMode.WriteOnly, bitmap1.PixelFormat);
                    byte[]     snapShot24 = new byte[bitmap1.Width * bitmap1.Height * 3]; // multiply by 3 to get 24bppRgb format
                    Marshal.Copy(bmpData.Scan0, snapShot24, 0, bitmap1.Width * bitmap1.Height * 3);
                    m_form.Invoke(m_form.m_DelegateSetImage, snapShot, snapShot24, (uint)bitmap1.Width, (uint)bitmap1.Height, template, templateLen, -1);
                }

                /////////////////////

                /////////////////

                LumiSDKWrapper.LUMI_PROCESSING_MODE processingMode;
                processingMode.bExtract = 0;
                processingMode.bLatent  = 0;
                processingMode.bSpoof   = 0;
                LumiSDKWrapper.LumiStatus pStatus = LumiSDKWrapper.GetProcessingMode(_hHandle, ref processingMode);
                if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture failed. Unable to Set the Spoof detection mode", m_form.Red);
                    return;
                }
                if (m_form.m_bSpoofEnabled)
                {
                    processingMode.bSpoof = 1;
                }
                else
                {
                    processingMode.bSpoof = 0;
                }

                pStatus = LumiSDKWrapper.SetProcessingMode(_hHandle, processingMode);
                if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture failed. Unable to Set the Spoof detection mode", m_form.Red);
                    return;
                }

                ////////////////
                LumiSDKWrapper.LumiStatus Status = CaptureImage(snapShot, snapShot24bpp, template, ref templateLen, width, height, ref nSpoof, del, ref nNFIQ);

                if (m_form.m_bClosingApp)
                {
                    CloseScanner();
                    return;
                }



                if (m_form.m_bNISTQuality)
                {
                    m_form.Invoke(m_form.m_DelegateNISTStatus, "NIST Quality = " + nNFIQ, m_form.Blue);
                    m_form.Invoke(m_form.m_DelegateSetNISTImage, nNFIQ);
                }
                else
                {
                    m_form.Invoke(m_form.m_DelegateNISTStatus, "", m_form.Blue);
                }
                if (Status == LumiSDKWrapper.LumiStatus.LUMI_STATUS_CANCELLED_BY_USER)
                {
                    m_form.Invoke(m_form.m_DelegateCaptureCancelled);
                    m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture Cancelled by User", m_form.Red);
                    //throw new Exception();
                    return;
                }
                if (Status == LumiSDKWrapper.LumiStatus.LUMI_STATUS_ERROR_TIMEOUT)
                {
                    m_form.Invoke(m_form.m_DelegateCaptureTimeOut);
                    m_form.Invoke(m_form.m_DelegateErrorMessage, "Sensor Time Out.", m_form.Red);

                    return;
                }
                if (Status == LumiSDKWrapper.LumiStatus.LUMI_STATUS_ERROR_TIMEOUT_LATENT)
                {
                    m_form.Invoke(m_form.m_DelegateCaptureTimeOut);
                    m_form.Invoke(m_form.m_DelegateErrorMessage, "Sensor Time Out.", m_form.Red);
                    return;
                }
                if (Status == LumiSDKWrapper.LumiStatus.LUMI_STATUS_ERROR_SENSOR_COMM_TIMEOUT)
                {
                    m_form.Invoke(m_form.m_DelegateComTimeOut);
                    m_form.Invoke(m_form.m_DelegateErrorMessage, "Sensor Communication Time Out.\n Please re-connect the device and restart the application", m_form.Red);
                    return;
                }

                m_form.Invoke(m_form.m_DelegateSetImage, snapShot, snapShot24bpp, width, height, template, templateLen, -1);
                GC.KeepAlive(del);
                if (Status == LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
                {
                    if (m_form.m_bSpoofEnabled && (nSpoof != -1))
                    {
                        if (nSpoof <= m_form.m_SpoofThreshold)
                        {
                            m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture Complete\r\nSpoofScore = " + nSpoof + ": It is a Real Finger", m_form.Blue);
                        }
                        else
                        {
                            m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture Complete\r\nSpoofScore = " + nSpoof + ": It is a Spoof", m_form.Red);
                        }
                    }
                    else
                    {
                        m_form.Invoke(m_form.m_DelegateErrorMessage, "Capture Complete", m_form.Blue);
                    }
                }
            }
            catch (Exception err)
            {
                string str = err.ToString();
                m_form.Invoke(m_form.m_DelegateErrorMessage, ("Error occured. Restart your application"), m_form.Red);
            }
            m_form.Invoke(m_form.m_CaptureThreadFinished);
        }
Ejemplo n.º 15
0
        public void Run()
        {
            uint width = 0, height = 0;
            int  nSpoof = 0;

            GetWidthAndHeight(ref width, ref height);
            byte[] snapShot24bpp = new byte[width * height * 3]; // multiply by 3 to get 24bppRgb format
            byte[] template1     = new byte[5000];               //array to hold the template
            byte[] template2     = new byte[5000];               //array to hold the template
            byte[] template3     = new byte[5000];               //array to hold the template


            uint templateLen1 = 0;
            uint templateLen2 = 0;
            uint templateLen3 = 0;

            uint nMatchScore1 = 0;
            uint nMatchScore2 = 0;
            uint nMatchScore3 = 0;

            int nSpoofScore = 0;

            LumiSDKWrapper.LumiPresenceDetectCallbackDelegate del = _form.PresenceDetectionCallback;
            ////////////////////////////
            LumiSDKWrapper.LUMI_PROCESSING_MODE processingMode;
            processingMode.bExtract = 0;
            processingMode.bLatent  = 0;
            processingMode.bSpoof   = 0;
            LumiSDKWrapper.LumiStatus pStatus = LumiSDKWrapper.GetProcessingMode(_hHandle, ref processingMode);
            if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
            {
                _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Unable to Set the Spoof detection mode", _form.Red);
                return;
            }

            processingMode.bSpoof = _form.m_bSpoofEnabled ? (byte)1 : (byte)0;

            pStatus = LumiSDKWrapper.SetProcessingMode(_hHandle, processingMode);

            if (pStatus != LumiSDKWrapper.LumiStatus.LUMI_STATUS_OK)
            {
                _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Unable to Set the Spoof detection mode", _form.Red);
                return;
            }

            //////////////////////////////////
            _form.Invoke(_form.m_DelegateErrorMessage, "Place finger down for first insertion", _form.Blue);
            if (EnrollAndDisplay(0, snapShot24bpp, template1, ref templateLen1, width, height, ref nSpoof, del) == false)
            {
                _form.Invoke(_form.m_EnrollThreadFinished);
                return;
            }

            if (_form.m_bClosingApp)
            {
                CloseScanner();
                return;
            }

            /////////////
            if (_form.m_bSpoofEnabled)
            {
                if (nSpoof > 1050)
                {
                    _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Please enroll with real finger", _form.Red);
                    _form.Invoke(_form.m_EnrollThreadFinished);
                    return;
                }
            }

            // Force Finger Lift between enrollment insertions
            _form.Invoke(_form.m_DelegateErrorMessage, "Please lift finger and place again", _form.Red);
            ForceFingerLift();

            _form.Invoke(_form.m_DelegateErrorMessage, "Place finger down for second insertion", _form.Blue);
            if (EnrollAndDisplay(1, snapShot24bpp, template2, ref templateLen2, width, height, ref nSpoof, del) == false)
            {
                _form.Invoke(_form.m_EnrollThreadFinished);
                return;
            }

            if (_form.m_bClosingApp)
            {
                CloseScanner();
                return;
            }

            if (_form.m_bSpoofEnabled)
            {
                if (nSpoof > 1050)
                {
                    _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Please enroll with real finger", _form.Red);
                    _form.Invoke(_form.m_EnrollThreadFinished);
                    return;
                }
            }

            // Force Finger Lift between enrollment insertions
            _form.Invoke(_form.m_DelegateErrorMessage, "Please lift finger and place again", _form.Red);
            ForceFingerLift();

            _form.Invoke(_form.m_DelegateErrorMessage, "Place finger down for third insertion", _form.Blue);
            if (EnrollAndDisplay(2, snapShot24bpp, template3, ref templateLen3, width, height, ref nSpoof, del) == false)
            {
                _form.Invoke(_form.m_EnrollThreadFinished);
                return;
            }

            if (_form.m_bClosingApp)
            {
                CloseScanner();
                return;
            }

            if (_form.m_bSpoofEnabled)
            {
                if (nSpoof > 1050)
                {
                    _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Please enroll with real finger", _form.Red);
                    _form.Invoke(_form.m_EnrollThreadFinished);
                    return;
                }
            }

            ///////////////

            /*
             * LumiSDKWrapper.LumiMatch(_hHandle, template2, ref templateLen2, template3, ref templateLen3, ref nMatchScore2, ref nSpoofScore);
             *
             * if (nMatchScore2 < _form.m_MatchThreshold)
             * {
             *  _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment failed. Please use the same finger for enrollment", _form.Red);
             *  _form.Invoke(_form.m_EnrollThreadFinished);
             *  return;
             * }
             * LumiSDKWrapper.LumiMatch(_hHandle, template1, ref templateLen1, template3, ref templateLen3, ref nMatchScore3, ref nSpoofScore);
             *
             * FileStream stream;
             * BinaryFormatter bformatter = new BinaryFormatter();
             *
             * if (_form.m_newSubjID)
             * {
             *  stream = File.Create(_form.m_sFolderPath + "\\Database\\" + _form.m_sEnrollSubjID + ".bin");
             * }
             * else
             * {
             *  stream = File.Open(_form.m_sFolderPath + "\\Database\\" + _form.m_sEnrollSubjID + ".bin", FileMode.Open);
             * }
             *
             *
             * _form.m_currentSubject.deleteData(_form.m_CurrentHotSpot);
             *
             * if(nMatchScore1>nMatchScore2)
             * {
             *  if (nMatchScore1 > nMatchScore3)
             *  {
             *      if (nMatchScore2 > nMatchScore3)
             *      {
             *          _form.m_currentSubject.addData(template2, templateLen2, _form.m_CurrentHotSpot);
             *
             *      }
             *      else
             *      {
             *          _form.m_currentSubject.addData(template1, templateLen1, _form.m_CurrentHotSpot);
             *
             *      }
             *
             *  }
             *  else
             *  {
             *      _form.m_currentSubject.addData(template1, templateLen1, _form.m_CurrentHotSpot);
             *  }
             *
             * }
             * else
             * {
             *  if (nMatchScore2 > nMatchScore3)
             *  {
             *      if (nMatchScore1 > nMatchScore3)
             *      {
             *          _form.m_currentSubject.addData(template2, templateLen2, _form.m_CurrentHotSpot);
             *      }
             *      else
             *      {
             *          _form.m_currentSubject.addData(template3, templateLen3, _form.m_CurrentHotSpot);
             *      }
             *  }
             *  else
             *  {
             *      _form.m_currentSubject.addData(template3, templateLen3, _form.m_CurrentHotSpot);
             *  }
             *
             * }
             *
             * bformatter.Serialize(stream, _form.m_currentSubject);
             * stream.Close();*/

            _form.Invoke(_form.m_DelegateErrorMessage, "Enrollment successful", _form.Blue);

            _form.Invoke(_form.m_EnrollThreadFinished);
        }