using System; using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; using System.Windows.Forms; using CaptureEye; using IAiCamIrisLib; namespace IrisCollectForm { public partial class Form1 : Form { //private iCamIrisClass m_iCamIrisLib = new iCamIrisClass(); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { textBox1.Text = ofd.FileName; } } private void button2_Click(object sender, EventArgs e) { Bitmap bitmap = new Bitmap(textBox1.Text); EyeParams eyeParams = new EyeParams(); CaptureEye.CaptureEye captureEye = new CaptureEye.CaptureEye(); AssessEye.AssessEye assess = new AssessEye.AssessEye(); int result = captureEye.M_CaptureEye(bitmap, out eyeParams); if (result == 0) { MessageBox.Show("未找到眼睛","提示"); } if (result == 1) { double score = assess.M_AssessEye(bitmap, eyeParams); } } private void button3_Click(object sender, EventArgs e) { //object iIrisode = null; //Bitmap bitmap = new Bitmap(textBox1.Text); //int width = bitmap.Width; //int height = bitmap.Height; //byte[] byImage = ImageToRaw8BitByteArray(bitmap, out width, out height); //int result = m_iCamIrisLib.CreateLongIrisCode(byImage, out iIrisode); } public static byte[] ImageToRaw8BitByteArray(Bitmap bitmapImage, out int width, out int height) { BitmapData bitmapData = bitmapImage.LockBits(new Rectangle(0, 0, bitmapImage.Width, bitmapImage.Height), ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed); int size = bitmapData.Width * bitmapData.Height; width = bitmapData.Width; height = bitmapData.Height; byte[] rawImage = new byte[size]; Marshal.Copy(bitmapData.Scan0, rawImage, 0, size); bitmapImage.UnlockBits(bitmapData); return rawImage; } /// <summary> /// 初始化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button_Init_Click(object sender, EventArgs e) { String strJson= "{\"white_brightness\":\"245\"}"; irisColCtrl1.IrisInit(strJson); } private void button_reset_Click(object sender, EventArgs e) { irisColCtrl1.ReSet(); } private void button_startCapture_Click(object sender, EventArgs e) { String strJson = "{\"eyeType\":\"1\"}"; irisColCtrl1.StartCapture(strJson); } private void button_stopCapture_Click(object sender, EventArgs e) { irisColCtrl1.StopCapture(); } private void button_close_Click(object sender, EventArgs e) { irisColCtrl1.IrisClose(); } private void button4_Click(object sender, EventArgs e) { //irisColCtrl1.OnCapture(); } } }