C# 4.0 从网络摄像头视频c保存视频时出错#
我需要一些关于错误的帮助。。 错误2“c:\Users\anton\OneDrive\БСimk_Мыы\Visual Studio 2013\Projects\WindowsFormsApplication4\packages\Accord.Video.3.0.2\lib\net45\Accord.Video.dll”和“c:\Users\anton\OneDrive\Documents\visualstudio”中都存在类型“AForge.Video.NewFrameEventArgs”2013\Projects\WindowsFormsApplication4\packages\AForge.Video.2.2.5\lib\AForge.Video.dll'C:\Users\anton\onedrive\Documents\visualstudio 2013\Projects\WindowsFormsApplication4\Form1.cs 50 42 WindowsFormsApplication4C# 4.0 从网络摄像头视频c保存视频时出错#,c#-4.0,C# 4.0,我需要一些关于错误的帮助。。 错误2“c:\Users\anton\OneDrive\БСimk_Мыы\Visual Studio 2013\Projects\WindowsFormsApplication4\packages\Accord.Video.3.0.2\lib\net45\Accord.Video.dll”和“c:\Users\anton\OneDrive\Documents\visualstudio”中都存在类型“AForge.Video.NewFrameEventArgs”20
this is 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;
using AForge.Video.DirectShow;
using AForge.Video.FFMPEG;
namespace WindowsFormsApplication4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private VideoCaptureDevice FinalVideo = null;
private VideoCaptureDeviceForm captureDevice;
private Bitmap video;
private VideoFileWriter FileWriter = new VideoFileWriter();
private SaveFileDialog saveAvi;
private FilterInfoCollection webcam;
private VideoCaptureDevice cam;
private void Form1_Load(object sender, EventArgs e)
{
webcam = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo VideoCaptureDevice in webcam)
{
comboBox1.Items.Add(VideoCaptureDevice.Name);
comboBox1.SelectedIndex = 0;
}
pictureBox1.Anchor = (AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom);
comboBox1.Anchor = (AnchorStyles.Bottom);
button1.Anchor = (AnchorStyles.Bottom);
button2.Anchor = (AnchorStyles.Bottom);
button3.Anchor = (AnchorStyles.Bottom);
}
private void button1_Click(object sender, EventArgs e)
{
cam = new VideoCaptureDevice(webcam[comboBox1.SelectedIndex].MonikerString);
cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
cam.Start();
}
void cam_NewFrame(object sender, NewFrameEventArgs EventArgs)
{
Bitmap bit = (Bitmap)EventArgs.Frame.Clone();
pictureBox1.Image = bit;
}
private void button3_Click(object sender, EventArgs e)
{
if (cam.IsRunning)
{
cam.Stop();
}
}
private void button2_Click(object sender, EventArgs e)
{
saveFileDialog1.InitialDirectory = @"C:\picture";
saveFileDialog1.Filter = "Images|*.png;*.bmp;*.jpg";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image.Save(saveFileDialog1.FileName);
}
}
private void button4_Click(object sender, EventArgs e)
{
saveAvi = new SaveFileDialog();
saveAvi.Filter = "Avi Files (*.avi)|*.avi";
if (saveAvi.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
int h = captureDevice.VideoDevice.VideoResolution.FrameSize.Height;
int w = captureDevice.VideoDevice.VideoResolution.FrameSize.Width;
FileWriter.Open(saveAvi.FileName, w, h, 25, VideoCodec.Default, 5000000);
FileWriter.WriteVideoFrame(video);
//AVIwriter.Open(saveAvi.FileName, w, h);
//FinalVideo = captureDevice.VideoDevice;
//FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
//FinalVideo.Start();
}
}
}
}
我还没有使用相关的库,所以我不能确定,但您确定要同时安装
a org.Video
和Accord.Video
?可能尝试删除其中一个。如果删除其中一个,则无法使用arge.Video.DirectShow或arge.Video.FFMPEG