Goodmorning everyone,
I am new to this forum and a beginner programmer;
I Created a program in C # with Visual Studio 2015 that, to the pressure of a button turns on the webcam , snaps a picture and displays it on a picture box; I adapted the Solution shown , from a Code that I Found on line but my ultimate good would another: I would like that , once you press the button, the photo was automatically saved in a specific folder ; The framework I used to perform operations on webcam is Aforge, but frankly I don't understand, from the documentation online of the library (aforge), how to perform the operation I have Just described; can you help me please?
I paste here my code:
thank you so much
Hello
simone
I am new to this forum and a beginner programmer;
I Created a program in C # with Visual Studio 2015 that, to the pressure of a button turns on the webcam , snaps a picture and displays it on a picture box; I adapted the Solution shown , from a Code that I Found on line but my ultimate good would another: I would like that , once you press the button, the photo was automatically saved in a specific folder ; The framework I used to perform operations on webcam is Aforge, but frankly I don't understand, from the documentation online of the library (aforge), how to perform the operation I have Just described; can you help me please?
I paste here my code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using AForge.Video.DirectShow; using AForge.Video.VFW; using AForge.Video; //using System.IO; namespace RiconoscimentoUtente2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } bool catturaFrame = false; VideoCaptureDevice webcam = null; Graphics superficieScatto = null; Rectangle rettangolo; private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { superficieScatto = Scatto.CreateGraphics(); rettangolo = Scatto.ClientRectangle; catturaFrame = true; if (webcam == null) { webcam = new VideoCaptureDevice("@device:pnp:\\\\?\\usb#vid_04f2&pid_b40e&mi_00#7&97d73eb&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global"); webcam.NewFrame += new NewFrameEventHandler(fotogramma); webcam.Start(); } using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\XXXXX pc\Desktop\RICONOSCIMENTO\SI.txt", true)) { //file.WriteLine("+++++"); MessageBox.Show("Ciao ZZZ!!!"); file.WriteLine(DateTime.Now); //file.WriteLine(); file.WriteLine("+++++"); } Application.Exit(); webcam.Stop(); //MessageBox.Show("Ciao ZZZZ!!!"); //this.Close(); } private void button2_Click(object sender, EventArgs e) { superficieScatto = Scatto.CreateGraphics(); rettangolo = Scatto.ClientRectangle; catturaFrame = true; if (webcam == null) { webcam = new VideoCaptureDevice("@device:pnp:\\\\?\\usb#vid_04f2&pid_b40e&mi_00#7&97d73eb&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\\global"); webcam.NewFrame += new NewFrameEventHandler(fotogramma); webcam.Start(); } using (System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\Users\XXXXX pc\Desktop\RICONOSCIMENTO\NO.txt", true)) { //file.WriteLine("+++++"); MessageBox.Show("Salve Ospite!!!"); file.WriteLine(DateTime.Now); //file.WriteLine(); file.WriteLine("+++++"); } Application.Exit(); webcam.Stop(); } void fotogramma(object sender, NewFrameEventArgs e) { if (catturaFrame) { superficieScatto.DrawImage(e.Frame, rettangolo); catturaFrame = false; //catturaFrame = true; } } } }
thank you so much
Hello
simone
Last edited by a moderator: