using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using MetroFramework.Forms; using System.Data.Odbc; using System.Data.SqlClient; using System.Configuration; using System.Media; using System.Drawing.Imaging; using Emgu.CV; using Emgu.CV.UI; using Emgu.CV.Structure; using Emgu.Util; using System.Runtime.InteropServices; namespace Visitor_GatePass_Management_System { // public partial class VisitorMasterPage : Form public partial class VisitorMasterPage : MetroForm { public VisitorMasterPage() { InitializeComponent(); } private Emgu.CV.Capture _capture; //private static Emgu.CV.Capture _capture; private bool _captureInProgress; //Emgu.CV.Capture _capture; //bool _captureInProgress; private void VisitorMasterPage_Load(object sender, EventArgs e) { lblpath.Text = "D:\\image.jpg"; } private void btncapphonto_Click(object sender, EventArgs e) { if ((this.lblpath.Text.Trim().Length > 0)) { if ((_capture==null)) { try { //_capture = new Emgu.CV.Capture(); _capture = new Capture(); } catch (NullReferenceException excpt) { MetroFramework.MetroMessageBox.Show(this, excpt.Message); } } if (((_capture != null))) { if (_captureInProgress) { this.btncapphonto.Text = "Start Capture"; // this.Load +=new EventHandler(this.ProcessFrame); //EventHandlerList list=(EventHandlerList) Application.Idle -= new EventHandler(this.ProcessFrame); this.pbphoto.Image.Save(this.lblpath.Text, ImageFormat.Jpeg); this.pbphoto.ImageLocation = this.lblpath.Text; } else { // captureButton.Text = "Capture" this.btncapphonto.Text = "Capture"; Application.Idle += new EventHandler(this.ProcessFrame); } _captureInProgress = !_captureInProgress; } } else { MetroFramework.MetroMessageBox.Show(this, "Please set directory path for saving the image."); } } private void ProcessFrame(object sender, EventArgs arg) { //Emgu.CV.Image[] frame(Emgu.CV.Structure.Bgr,Byte)= this._capture.QueryFrame; Emgu.CV.Image frame = this._capture.QueryFrame(); Emgu.CV.Image frame1 = frame.Resize(150, 150,Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR); pbphoto.Image = frame1.Bitmap; } private void btnSaveVisitorMaster_Click(object sender, EventArgs e) { } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)