Thứ Năm, 17 tháng 4, 2014

Lập trình C# với thư viện AFore chụp hình từ Webcam, lưu thành file ảnh (Extraction Image Frame from Video)

1. Ảnh lưu được dạng jpg

2. Giao diện chính của chương trình Kết nối tới Webcam 


- Hệ thống tự nhận dạng ra webcam và kết nối với máy tính
- Hệ thống truyền hình trực tiếp hình ảnh thu được từ cảnh
- Nhận nút Trigger để dừng hình và lưu thành file ảnh.

3. Ngoài những thư viện thường dùng của C# đối với Form, phần mềm còn sử dụng 2 thư viện của AForge là: 

//Thư viện thường dùng của C# khi thiết kế form
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

//Thu viện video của AFore
using AForge.Video;
using AForge.Video.DirectShow;

4. Không gian tên snapshot_maker định nghĩa một lớp đối tượng MainForm có các trường dữ liệu và các hàm như sau:

  private FilterInfoCollection videoDevices;
       // Fileds
        private VideoCaptureDevice videoDevice;
        private VideoCapabilities[] videoCapabilities;
        private VideoCapabilities[] snapshotCapabilities;
        private SnapshotForm snapshotForm = null;

        //Method
 public MainForm( ) {}
 private void MainForm_Load( object sender, EventArgs e ) {}
 private void MainForm_FormClosing( object sender, FormClosingEventArgs e ) {}
 private void EnableConnectionControls( bool enable ) {}
 private void devicesCombo_SelectedIndexChanged( object sender, EventArgs e ) {}
 private void EnumeratedSupportedFrameSizes( VideoCaptureDevice videoDevice ) {}
 private void connectButton_Click( object sender, EventArgs e ) {}
 private void disconnectButton_Click( object sender, EventArgs e ) {}
 private void Disconnect( ) {}
 private void triggerButton_Click( object sender, EventArgs e ) {}
 private void videoDevice_SnapshotFrame( object sender, NewFrameEventArgs eventArgs ) {}
 private void ShowSnapshot( Bitmap snapshot ) {}
 private void snapshotForm_FormClosed( object sender, FormClosedEventArgs e ) {}





Không có nhận xét nào:

Đăng nhận xét