摄像头组件,支持novif和http协议
This commit is contained in:
72
Windows/CS/Framework4.0/Camera/Test/Form1.cs
Normal file
72
Windows/CS/Framework4.0/Camera/Test/Form1.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
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 Camera;
|
||||
|
||||
namespace Test
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private Camera.Camera _camera;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_camera = new Camera.Camera();
|
||||
_camera.ImageCaptured += Camera_ImageCaptured;
|
||||
}
|
||||
|
||||
private void Camera_ImageCaptured(object sender, ImageEventArgs e)
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new Action<Image>(UpdatePictureBox), e.Image);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePictureBox(e.Image);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePictureBox(Image image)
|
||||
{
|
||||
if (pictureBox1.Image != null)
|
||||
{
|
||||
pictureBox1.Image.Dispose();
|
||||
}
|
||||
pictureBox1.Image = image;
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (button1.Text == "获取摄像头图像")
|
||||
{
|
||||
button1.Text = "停止获取";
|
||||
_camera.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
button1.Text = "获取摄像头图像";
|
||||
_camera.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void button2_Click(object sender, EventArgs e)
|
||||
{
|
||||
Camera.Setting settingForm = new Camera.Setting();
|
||||
settingForm.ShowDialog();
|
||||
}
|
||||
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
_camera.Stop();
|
||||
base.OnFormClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user