C#/ WPF开源相机库

时间:2016-10-13 13:28:50

标签: c# .net wpf camera

我没有使用.Net项目一段时间,现在我需要使用一个库来显示网络摄像头的实时视图并拍照或制作视频。任何人都可以建议我一个很好的开源库吗?快速搜索后,我找到了 AForge 库,但我不知道它是否是我正在寻找的。

1 个答案:

答案 0 :(得分:0)

之前我使用过WebCam_Capture;

WebCAM.cs:

using System;
using System.IO;
using System.Linq;
using System.Text;
using WebCam_Capture;
using System.Collections.Generic;
namespace controlPC{
 class WebCam{
private WebCamCapture webcam;
private System.Windows.Forms.PictureBox _FrameImage;
private int FrameNumber = 50;
 public void InitializeWebCam(ref System.Windows.Forms.PictureBox ImageControl){
 webcam = new WebCamCapture();
  webcam.FrameNumber = ((ulong)(0ul));
 webcam.TimeToCapture_milliseconds = FrameNumber;
 webcam.ImageCaptured += new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);
_FrameImage = ImageControl;}
 void webcam_ImageCaptured(object source, WebcamEventArgs e){
 _FrameImage.Image = e.WebCamImage;}
  public void Start(){
 webcam.TimeToCapture_milliseconds = FrameNumber;
 webcam.Start(0);}
 public void Stop(){
 webcam.Stop();}
 public void Continue(){
 webcam.TimeToCapture_milliseconds = FrameNumber;
 webcam.Start(this.webcam.FrameNumber);}

MainForm.cs

using WebCam_Capture;
    void MainFormLoad(object sender, EventArgs e)
{
 webcam = new WebCam();
webcam.InitializeWebCam(ref pictureBox1);
}