Ejemplo n.º 1
0
        private uint MakeFIRFromRawSet(NBioBSPISO4.NIMPORTRAWSET RawSet, out NBioAPI.Type.HFIR hProcessedFIR)
        {
            hProcessedFIR = null;

            if (RawSet.nDataCount < 1)
            {
                return(NBioAPI.Error.FUNCTION_FAIL);
            }

            uint      nRet;
            int       i, j, k;
            ushort    nWidth        = RawSet.ImportRawData[0].nImgWidth;
            ushort    nHeight       = RawSet.ImportRawData[0].nImgHeight;
            const int FINGER_ID_MAX = 11;

            byte[] arSampleCnt = new byte[FINGER_ID_MAX];
            byte   nSampleCnt  = 0;
            string szTemp;

            listRet.Items.Add("NITGEN FIR creation start...");

            for (i = 0; i < FINGER_ID_MAX; i++)
            {
                arSampleCnt[i] = 0;
            }

            // Image size check
            for (i = 0; i < RawSet.nDataCount; i++)
            {
                if (nWidth != RawSet.ImportRawData[i].nImgWidth || nHeight != RawSet.ImportRawData[i].nImgHeight)
                {
                    return(NBioAPI.Error.FUNCTION_FAIL);
                }

                arSampleCnt[RawSet.ImportRawData[i].nFingerID]++;
            }

            // Sample per finger check
            for (i = 0; i < FINGER_ID_MAX; i++)
            {
                if (nSampleCnt == 0)
                {
                    nSampleCnt = arSampleCnt[i];
                }
                else
                {
                    if (arSampleCnt[i] != 0 && nSampleCnt != arSampleCnt[i])
                    {
                        return(NBioAPI.Error.FUNCTION_FAIL);
                    }
                }
            }

            if (nSampleCnt < 1 || nSampleCnt > 2)
            {
                return(NBioAPI.Error.FUNCTION_FAIL);
            }

            // Make NBioAPI_EXPORT_AUDIT_DATA
            NBioAPI.Export.EXPORT_AUDIT_DATA exportAuditData;

            exportAuditData = new NBioAPI.Export.EXPORT_AUDIT_DATA();

            exportAuditData.FingerNum        = (byte)(RawSet.nDataCount / nSampleCnt);
            exportAuditData.SamplesPerFinger = nSampleCnt;
            exportAuditData.ImageWidth       = nWidth;
            exportAuditData.ImageHeight      = nHeight;
            exportAuditData.AuditData        = new NBioAPI.Export.AUDIT_DATA[exportAuditData.FingerNum];

            for (i = 0; i < exportAuditData.FingerNum; i++)
            {
                exportAuditData.AuditData[i].Image = new NBioAPI.Export.IMAGE_DATA[exportAuditData.SamplesPerFinger];

                for (j = 0; j < FINGER_ID_MAX; j++)
                {
                    if (arSampleCnt[j] != 0)
                    {
                        exportAuditData.AuditData[i].FingerID = (byte)j;
                        arSampleCnt[j] = 0;
                        break;
                    }
                }

                for (j = 0, k = 0; j < RawSet.nDataCount; j++)
                {
                    if (exportAuditData.AuditData[i].FingerID == RawSet.ImportRawData[j].nFingerID)
                    {
                        exportAuditData.AuditData[i].Image[k].Data   = new byte[RawSet.ImportRawData[j].RawData.Length];
                        exportAuditData.AuditData[i].Image[k++].Data = RawSet.ImportRawData[j].RawData;
                    }
                }
            }

            // Make Image handle
            NBioAPI.Type.HFIR hAuditFIR;

            nRet = m_Export.ImageToNBioBSP(exportAuditData, out hAuditFIR);

            if (nRet == NBioAPI.Error.NONE)
            {
                // Make FIR handle
                nRet = m_NBioAPI.Process(hAuditFIR, out hProcessedFIR);

                if (nRet != NBioAPI.Error.NONE)
                {
                    szTemp = "Process Error: " + nRet;
                    listRet.Items.Add(szTemp);
                }

                hAuditFIR.Dispose();
            }
            else
            {
                szTemp = "ImageToNBioBSP Error: " + nRet;
                listRet.Items.Add(szTemp);
            }

            return(nRet);
        }