private bool SetPreview() { #region SetPreview switch (this._selectedPrevMode) { case PrevMode.directDraw: RSRect rect = new RSRect(); RS_SDK.GetClientRect(PreviewWindow.Handle, ref rect); m_result = RS_SDK.RS_SetViewWindow(this.deviceHandle, PreviewWindow.Handle, rect, false); if (m_result != RS_SDK.RS_SUCCESS) { RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); MsgPanel.Text = m_errorMsg; return(false); } m_prevStopped = false; //ClearAllOverlays.Enabled = true; //DrawOverlay.Enabled = true; PreviewWindow.Invalidate(); PreviewWindow.Show(); break; //case PrevMode.callbackDraw: // m_result = RS_SDK.RS_RegisterPreviewCallback(deviceHandle, previewCallback); // if (m_result != RS_SDK.RS_SUCCESS) // { // RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); // MsgPanel.Text = m_errorMsg; // } // break; //case PrevMode.advCallbackDraw: // m_result = RS_SDK.RS_RegisterAdvPreviewCallback(deviceHandle, advPreviewCallback); // if (m_result != RS_SDK.RS_SUCCESS) // { // RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); // MsgPanel.Text = m_errorMsg; // } // break; default: break; } return(true); #endregion }
private void clbPulgar_SelectedIndexChanged(object sender, EventArgs e) { #region clbPulgar_SelectedValueChanged int n = 0; for (int i = 0; i < 2; i++) { if (clbPulgar.GetItemChecked(i)) { n++; } } m_minCount = 2 - n; m_result = RS_SDK.RS_SetMinimumFinger(deviceHandle, m_minCount); if (m_result != RS_SDK.RS_SUCCESS) { RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); MsgPanel.Text = m_errorMsg; } #endregion }
private void SegmentSaveImageCaptureProcess(IntPtr imageData, int imageWidth, int imageHeight, int numOfFingers, RSSlapInfoArray slapInfo, IntPtr[] ImageBuffer, int[] ImageWidth, int[] ImageHeight) { #region SegmentSaveImageCaptureProcess string bmp; string wsq; int dedo = 0; int result; int n = 0; byte[] huella = null; byte[] template = null; byte[] archivoWSQMem = null; int[] dedoPerdido = new int[] { 0, 0, 0, 0 }; int[] pulgarPerdido = new int[] { 0, 0 }; string palma; try { #region genera arreglo para identificar dedo sin huella switch (param[0]) { case "3": //PULGARES for (int i = 0; i < 2; i++) { if (clbPulgar.GetItemChecked(i)) { switch (i) { case 0: dedoPerdido[0] = 0; break; case 1: dedoPerdido[1] = 0; break; break; } } else { switch (i) { case 0: dedoPerdido[0] = 6; break; case 1: dedoPerdido[1] = 1; break; } } } break; case "4": //4 DEDOS MANO IZQUIERDA for (int i = 0; i < 4; i++) { if (clbDedo.GetItemChecked(i)) { switch (i) { case 0: dedoPerdido[0] = 0; break; case 1: dedoPerdido[1] = 0; break; case 2: dedoPerdido[2] = 0; break; case 3: dedoPerdido[3] = 0; break; } } else { switch (i) { case 0: dedoPerdido[0] = 10; break; case 1: dedoPerdido[1] = 9; break; case 2: dedoPerdido[2] = 8; break; case 3: dedoPerdido[3] = 7; break; } } } break; case "5": //4 DEDOS MANO DERECHA for (int i = 0; i < 4; i++) { if (clbDedo.GetItemChecked(i)) { switch (i) { case 0: dedoPerdido[3] = 0; break; case 1: dedoPerdido[2] = 0; break; case 2: dedoPerdido[1] = 0; break; case 3: dedoPerdido[0] = 0; break; } } else { switch (i) { case 0: dedoPerdido[3] = 5; break; case 1: dedoPerdido[2] = 4; break; case 2: dedoPerdido[1] = 3; break; case 3: dedoPerdido[0] = 2; break; } } } break; default: break; } #endregion #region codigo comentado //GENERA BMP DE LAS 4 HUELLAS //palma = param[1] + "palma_" + param[0] + ".bmp"; //RS_SDK.RS_SaveBitmap(imageData, imageWidth, imageHeight, palma); //if (m_result != RS_SDK.RS_SUCCESS) //{ // RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); // MsgPanel.Text = m_errorMsg; //} #endregion //me conecto a la base de datos conn = new OracleConnection(Conexion(param[3])); conn.Open(); //ciclo que recorre el arreglo de huellas for (int i = 0; i < numOfFingers; i++) { //identifico el id del dedo que se le asignara a la huella dedo = 0; while (dedo == 0) { dedo = dedoPerdido[n]; n++; } //genero el nombre de los archivos y su ruta bmp = param[1] + param[2] + "_" + dedo + ".bmp"; wsq = param[1] + param[2] + "_" + dedo + ".wsq"; //genero imagen de la huella result = RS_SDK.RS_SaveBitmap(ImageBuffer[i], ImageWidth[i], ImageHeight[i], bmp); //cargo ewn memoria el archivo de la huella FileStream fs = new FileStream(bmp, FileMode.Open, FileAccess.Read); huella = new byte[fs.Length]; fs.Read(huella, 0, System.Convert.ToInt32(fs.Length)); fs.Close(); #region CODIGO DE PREUEBAS //result = RealScanExtendSDK.RSE_SaveRAW(ImageBuffer[i], ImageWidth[i], ImageHeight[i], "C:\\Temp\\huellas\\huella."+ "_" + dedo +"dat"); //creo el template... //template = new byte[ImageWidth[i] * ImageHeight[i]]; //Marshal.Copy(ImageBuffer[i], template, 0, ImageWidth[i] * ImageHeight[i]); #endregion //genero el archivo wsq RealScanExtendSDK.RSE_CompressWSQ(bmp, null, 3, wsq); //cargo en memoria el archivo wsq FileStream archivoWSQ = new FileStream(wsq, FileMode.Open, FileAccess.Read); archivoWSQMem = new byte[archivoWSQ.Length]; archivoWSQ.Read(archivoWSQMem, 0, System.Convert.ToInt32(archivoWSQ.Length)); archivoWSQ.Close(); //metodo que graba el registro en la base de datos RegistraHuella(dedo, huella, template, archivoWSQMem); //elimino los archivos del equipo File.Delete(bmp); File.Delete(wsq); } conn.Close(); conn.Dispose(); } catch (TargetInvocationException ex) { MsgPanel.Text = ex.Message; throw; } #endregion }
private bool SegmentCaptureProcess(IntPtr imageData, int imageWidth, int imageHeight, int deviceHandle, ref RSSlapInfoArray slapInfo, ref int numOfFingers, ref IntPtr[] ImageBuffer, ref int[] ImageWidth, ref int[] ImageHeight) { #region SegmentCaptureProcess RSSlapInfoArray slapInfoA = new RSSlapInfoArray(); IntPtr slapInfoArray; int captureMode = 0; int captureOption = 0; int slapType = 1; for (int i = 0; i < 4; i++) { ImageBuffer[i] = (IntPtr)0; ImageWidth[i] = 0; ImageHeight[i] = 0; } int _size = Marshal.SizeOf(typeof(RSSlapInfoArray)); slapInfoArray = Marshal.AllocHGlobal(_size); Marshal.StructureToPtr(slapInfoA, slapInfoArray, true); int fingerType = 0; int[] missingFingerArray = new int[] { 0, 0, 0, 0 }; int n = 0; //if (m_captureDir != RS_SDK.RS_CAPTURE_DIRECTION_DEFAULT) //{ // int captureDir = RS_SDK.RS_CAPTURE_DIRECTION_DEFAULT; // m_result = RS_SDK.RS_GetCaptureModeWithDir(deviceHandle, ref captureMode, ref captureDir, ref captureOption); //} //else m_result = RS_SDK.RS_GetCaptureMode(deviceHandle, ref captureMode, ref captureOption); if (m_result != RS_SDK.RS_SUCCESS) { RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); MsgPanel.Text = m_errorMsg; } switch (captureMode) { case RS_SDK.RS_CAPTURE_FLAT_TWO_FINGERS: case RS_SDK.RS_CAPTURE_FLAT_TWO_FINGERS_EX: slapType = RS_SDK.RS_SLAP_TWO_FINGER; break; case RS_SDK.RS_CAPTURE_FLAT_SINGLE_FINGER: case RS_SDK.RS_CAPTURE_FLAT_SINGLE_FINGER_EX: slapType = RS_SDK.RS_SLAP_ONE_FINGER; break; case RS_SDK.RS_CAPTURE_FLAT_LEFT_FOUR_FINGERS: slapType = RS_SDK.RS_SLAP_LEFT_FOUR; for (int i = 0; i < 4; i++) { if (clbDedo.GetItemChecked(i)) { missingFingerArray[n++] = RS_SDK.RS_FGP_LEFT_LITTLE - i; } } fingerType = RS_SDK.RS_FGP_LEFT_LITTLE; break; case RS_SDK.RS_CAPTURE_FLAT_RIGHT_FOUR_FINGERS: slapType = RS_SDK.RS_SLAP_RIGHT_FOUR; for (int i = 0; i < 4; i++) { if (clbDedo.GetItemChecked(i)) { missingFingerArray[n++] = i + RS_SDK.RS_FGP_RIGHT_INDEX; } } fingerType = RS_SDK.RS_FGP_RIGHT_INDEX; break; default: MsgPanel.Text = "Cannot segment in this mode"; return(false); } m_result = RS_SDK.RS_Segment4(imageData, imageWidth, imageHeight, slapType, ref numOfFingers, ref slapInfoArray, ref ImageBuffer[0], ref ImageWidth[0], ref ImageHeight[0], ref ImageBuffer[1], ref ImageWidth[1], ref ImageHeight[1], ref ImageBuffer[2], ref ImageWidth[2], ref ImageHeight[2], ref ImageBuffer[3], ref ImageWidth[3], ref ImageHeight[3]); if (m_result != RS_SDK.RS_SUCCESS) { if (m_result == RS_SDK.RS_ERR_SEGMENT_FEWER_FINGER) { if (m_minCount != numOfFingers) { RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); MsgPanel.Text = m_errorMsg; return(false); } } else { RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); MsgPanel.Text = m_errorMsg; return(false); } } MsgPanel.Text = "Calidad:"; slapInfoA = (RSSlapInfoArray)Marshal.PtrToStructure(slapInfoArray, typeof(RSSlapInfoArray)); if (slapInfoArray != (IntPtr)0) { RS_SDK.RS_FreeImageData(slapInfoArray); } int overlayHandle = -1; int j = 0; for (int i = 0; i < numOfFingers; i++) { if (slapInfoA.RSSlapInfoA[i].fingerType == RS_SDK.RS_FGP_UNKNOWN) { if (slapType == RS_SDK.RS_SLAP_LEFT_FOUR) { while (fingerType == missingFingerArray[j]) { fingerType--; j++; } slapInfoA.RSSlapInfoA[i].fingerType = fingerType--; } else if (slapType == RS_SDK.RS_SLAP_RIGHT_FOUR) { while (fingerType == missingFingerArray[j]) { fingerType++; j++; } slapInfoA.RSSlapInfoA[i].fingerType = fingerType++; } } slapInfo = slapInfoA; Enrolar. RSOverlayQuadrangle quad = new RSOverlayQuadrangle(); quad.pos = new RSPoint[4]; quad.color = 0x00ff0000; RSRect rect = new RSRect(); RS_SDK.GetClientRect(PreviewWindow.Handle, ref rect); quad.pos[0].x = slapInfoA.RSSlapInfoA[i].fingerPosition[0].x * rect.right / imageWidth; quad.pos[0].y = slapInfoA.RSSlapInfoA[i].fingerPosition[0].y * rect.bottom / imageHeight; quad.pos[1].x = slapInfoA.RSSlapInfoA[i].fingerPosition[1].x * rect.right / imageWidth; quad.pos[1].y = slapInfoA.RSSlapInfoA[i].fingerPosition[1].y * rect.bottom / imageHeight; quad.pos[2].x = slapInfoA.RSSlapInfoA[i].fingerPosition[3].x * rect.right / imageWidth; quad.pos[2].y = slapInfoA.RSSlapInfoA[i].fingerPosition[3].y * rect.bottom / imageHeight; quad.pos[3].x = slapInfoA.RSSlapInfoA[i].fingerPosition[2].x * rect.right / imageWidth; quad.pos[3].y = slapInfoA.RSSlapInfoA[i].fingerPosition[2].y * rect.bottom / imageHeight; m_result = RS_SDK.RS_AddOverlayQuadrangle(deviceHandle, ref quad, ref overlayHandle); m_result = RS_SDK.RS_ShowOverlay(overlayHandle, true); if (m_result != RS_SDK.RS_SUCCESS) { MsgPanel.Text = "Cannot overlay for quadrangle" + m_result; return(false); } } for (int i = 0; i < numOfFingers; i++) { MsgPanel.Text += "[" + slapInfoA.RSSlapInfoA[i].fingerType + ":" + slapInfoA.RSSlapInfoA[i].imageQuality + "] "; } return(true); #endregion }
private void DoautoCapture() { #region DoautoCapture int n; try { m_result = RS_SDK.RS_RemoveAllOverlay(deviceHandle); if (m_result != RS_SDK.RS_SUCCESS) { if (MsgPanel.InvokeRequired) { afterAutoCaptureCallback callback = new afterAutoCaptureCallback(captureProcess); try { this.Invoke(callback, m_result); } catch { } } else { RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); MsgPanel.Text = m_errorMsg; } return; } if (clbDedo.Visible) { n = 0; for (int i = 0; i < 4; i++) { if (clbDedo.GetItemChecked(i)) { n++; } } m_minCount = m_minCount - n; m_result = RS_SDK.RS_SetMinimumFinger(deviceHandle, m_minCount); if (m_result != RS_SDK.RS_SUCCESS) { RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); MsgPanel.Text = m_errorMsg; } } else { n = 0; for (int i = 0; i < 2; i++) { if (clbPulgar.GetItemChecked(i)) { n++; } } m_minCount = m_minCount - n; m_result = RS_SDK.RS_SetMinimumFinger(deviceHandle, m_minCount); if (m_result != RS_SDK.RS_SUCCESS) { RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); MsgPanel.Text = m_errorMsg; } } m_result = RS_SDK.RS_TakeImageData(deviceHandle, 10000, ref capturedImageData, ref capturedImageWidth, ref capturedImageHeight); if (m_result != RS_SDK.RS_SUCCESS) { if (capturedImageData != (IntPtr)0) { RS_SDK.RS_FreeImageData(capturedImageData); } } if (MsgPanel.InvokeRequired) { afterAutoCaptureCallback callback = new afterAutoCaptureCallback(captureProcess); try { this.Invoke(callback, m_result); } catch { } } else { RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); MsgPanel.Text = m_errorMsg; } } catch (Exception ex) { return; } #endregion }
private void CaptureMode_SelectedIndexChanged(object sender, EventArgs e) { #region CaptureMode_SelectedIndexChanged int[] tmpCaptureModes = new int[15] { RS_SDK.RS_CAPTURE_DISABLED, RS_SDK.RS_CAPTURE_ROLL_FINGER, RS_SDK.RS_CAPTURE_FLAT_SINGLE_FINGER, RS_SDK.RS_CAPTURE_FLAT_TWO_FINGERS, RS_SDK.RS_CAPTURE_FLAT_LEFT_FOUR_FINGERS, RS_SDK.RS_CAPTURE_FLAT_RIGHT_FOUR_FINGERS, RS_SDK.RS_CAPTURE_FLAT_LEFT_PALM, RS_SDK.RS_CAPTURE_FLAT_RIGHT_PALM, RS_SDK.RS_CAPTURE_FLAT_SINGLE_FINGER_EX, RS_SDK.RS_CAPTURE_FLAT_TWO_FINGERS_EX, RS_SDK.RS_CAPTURE_FLAT_LEFT_SIDE_PALM, RS_SDK.RS_CAPTURE_FLAT_RIGHT_SIDE_PALM, RS_SDK.RS_CAPTURE_FLAT_LEFT_WRITERS_PALM, RS_SDK.RS_CAPTURE_FLAT_RIGHT_WRITERS_PALM, RS_SDK.RS_CAPTURE_FLAT_MANUAL }; m_captureMode = Convert.ToInt16(param[0]); switch (m_captureMode) { case RS_SDK.RS_CAPTURE_FLAT_SINGLE_FINGER: case RS_SDK.RS_CAPTURE_FLAT_SINGLE_FINGER_EX: m_slapType = RS_SDK.RS_SLAP_ONE_FINGER; m_fingerCount = 1; m_minCount = 1; break; case RS_SDK.RS_CAPTURE_FLAT_TWO_FINGERS: case RS_SDK.RS_CAPTURE_FLAT_TWO_FINGERS_EX: m_slapType = RS_SDK.RS_SLAP_TWO_THUMB; m_fingerCount = 2; m_minCount = 2; break; case RS_SDK.RS_CAPTURE_FLAT_LEFT_FOUR_FINGERS: m_slapType = RS_SDK.RS_SLAP_LEFT_FOUR; m_fingerCount = 4; m_minCount = 4; break; case RS_SDK.RS_CAPTURE_FLAT_RIGHT_FOUR_FINGERS: m_slapType = RS_SDK.RS_SLAP_RIGHT_FOUR; m_fingerCount = 4; m_minCount = 4; break; default: break; } int[] nCaptDir = new int[3] { RS_SDK.RS_CAPTURE_DIRECTION_DEFAULT, RS_SDK.RS_CAPTURE_DIRECTION_LEFT, RS_SDK.RS_CAPTURE_DIRECTION_RIGHT }; m_result = RS_SDK.RS_SetCaptureModeWithDir(deviceHandle, m_captureMode, nCaptDir[m_captureDir], 0, true); if (m_result != RS_SDK.RS_SUCCESS) { RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); MsgPanel.Text = m_errorMsg; //CaptureMode.SelectedIndex = 0; m_bCaptureModeSelected = false; return; } #endregion }
private void SegmentSaveImageCaptureProcess(IntPtr imageData, int imageWidth, int imageHeight, int numOfFingers, RSSlapInfoArray slapInfo, IntPtr[] ImageBuffer, int[] ImageWidth, int[] ImageHeight) { #region SegmentSaveImageCaptureProcess SaveFileDialog saveDialog = new SaveFileDialog(); saveDialog.InitialDirectory = ".:\\"; saveDialog.FilterIndex = 1; string bmp; string wsq; int result; byte[] huella = null; byte[] wsqBuffer = null; int dedo = 0; int tamano = 0; byte[] template = null; int[] dedoPerdido = new int[] { 0, 0, 0, 0 }; int[] pulgarPerdido = new int[] { 0, 0 }; int n = 0; try { #region genera arreglo para identificar dedo sin huella switch (param[0]) { case "3": //PULGARES for (int i = 0; i < 2; i++) { if (clbPulgar.GetItemChecked(i)) { switch (i) { case 0: dedoPerdido[0] = 0; break; case 1: dedoPerdido[1] = 0; break; break; } } else { switch (i) { case 0: dedoPerdido[0] = 6; break; case 1: dedoPerdido[1] = 1; break; } } } break; case "4": //4 DEDOS MANO IZQUIERDA for (int i = 0; i < 4; i++) { if (clbDedo.GetItemChecked(i)) { switch (i) { case 0: dedoPerdido[0] = 0; break; case 1: dedoPerdido[1] = 0; break; case 2: dedoPerdido[2] = 0; break; case 3: dedoPerdido[3] = 0; break; } } else { switch (i) { case 0: dedoPerdido[0] = 10; break; case 1: dedoPerdido[1] = 9; break; case 2: dedoPerdido[2] = 8; break; case 3: dedoPerdido[3] = 7; break; } } } break; case "5": //4 DEDOS MANO DERECHA for (int i = 0; i < 4; i++) { if (clbDedo.GetItemChecked(i)) { switch (i) { case 0: dedoPerdido[3] = 0; break; case 1: dedoPerdido[2] = 0; break; case 2: dedoPerdido[1] = 0; break; case 3: dedoPerdido[0] = 0; break; } } else { switch (i) { case 0: dedoPerdido[3] = 5; break; case 1: dedoPerdido[2] = 4; break; case 2: dedoPerdido[1] = 3; break; case 3: dedoPerdido[0] = 2; break; } } } break; default: break; } #endregion //RS_SDK.RS_SaveBitmap(imageData, imageWidth, imageHeight, param[1] + param[2] + ".bmp"); //if (m_result != RS_SDK.RS_SUCCESS) //{ // RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); // MsgPanel.Text = m_errorMsg; //} conn = new OracleConnection(Conexion(param[3])); conn.Open(); for (int i = 0; i < numOfFingers; i++) { dedo = 0; while (dedo == 0) { dedo = dedoPerdido[n]; n++; } bmp = param[1] + param[2] + "_" + dedo + ".bmp"; wsq = param[1] + param[2] + "_" + dedo + ".wsq"; result = RS_SDK.RS_SaveBitmap(ImageBuffer[i], ImageWidth[i], ImageHeight[i], bmp); //result = RS_SDK.RS_EncodeWSQ(ImageBuffer[i], ImageWidth[i], ImageHeight[i], 0.75, ref wsqBuffer, ref tamano); //result = RealScanExtendSDK.RSE_CompressWSQ(bmp, null, 0.75, wsq); FileStream fs = new FileStream(bmp, FileMode.Open, FileAccess.Read); huella = new byte[fs.Length]; fs.Read(huella, 0, System.Convert.ToInt32(fs.Length)); fs.Close(); //result = RS_SDK.RS_SaveBitmapMem(ImageBuffer[i], ImageWidth[i], ImageHeight[i], huella); template = new byte[ImageWidth[i] * ImageHeight[i]]; Marshal.Copy(ImageBuffer[i], template, 0, ImageWidth[i] * ImageHeight[i]); RegistraHuella(dedo, huella, template); File.Delete(bmp); //result = RealScanExtendSDK.RSE_CompressWSQ(bmp, null, 2.25, wsq); //result = RealScanExtendSDK.RSE_CompressWSQBuffer(bmp, null, 0.75, memwsq, tamano); if (m_result != RS_SDK.RS_SUCCESS) { RS_SDK.RS_GetErrString(m_result, ref m_errorMsg); MsgPanel.Text = m_errorMsg; } } conn.Close(); conn.Dispose(); } catch (Exception ex) { MsgPanel.Text = ex.Message; } #endregion }