我一直在研究生成和读取(解码)QR码的应用程序。在解码部分,用户捕获QR码的图片,程序将开始解码过程。 我的问题是我不知道如何拍照。 P.S: 如果您提供库,请提供一个链接,其中包含使用该库的教程。 谢谢。从c摄像头捕获图像#
0
A
回答
0
我一直在寻找网络摄像机录音很长一段时间,你可以使用Aforge.NET。
下面是使用相同的代码WPF:
public partial class MainWindow : Window
{
private FilterInfoCollection VideoCaptureDevices;
private VideoCaptureDevice FinalVideo;
public VideoFileWriter writer= new VideoFileWriter();
public MainWindow()
{
InitializeComponent();
VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
foreach (FilterInfo VideoCaptureDevice in VideoCaptureDevices)
{
comboBox1.Items.Add(VideoCaptureDevice.Name);
}
comboBox1.SelectedIndex = 0;
}
private void button1_Click(object sender, EventArgs e)
{
writer.Open(@"d:\\newVid.avi", 640, 480, 25, VideoCodec.MPEG4);
FinalVideo = new VideoCaptureDevice(VideoCaptureDevices[comboBox1.SelectedIndex].MonikerString);
FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame);
FinalVideo.Start();
}
void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
System.Drawing.Image imgforms = (Bitmap)eventArgs.Frame.Clone();
Bitmap bmp = (Bitmap)eventArgs.Frame.Clone();
BitmapImage bi = new BitmapImage();
bi.BeginInit();
MemoryStream ms = new MemoryStream();
imgforms.Save(ms, ImageFormat.Bmp);
ms.Seek(0, SeekOrigin.Begin);
bi.StreamSource = ms;
bi.EndInit();
//Using the freeze function to avoid cross thread operations
bi.Freeze();
//Calling the UI thread using the Dispatcher to update the 'Image' WPF control
Dispatcher.BeginInvoke(new ThreadStart(delegate
{
pictureBox1.Source = bi; /*frameholder is the name of the 'Image' WPF control*/
}));
for (int i = 0; i < 2; i++)
{
writer.WriteVideoFrame(bmp);
}
}
private void Stop_Click(object sender, RoutedEventArgs e)
{
writer.Close();
FinalVideo.Stop();
this.Close();
}
}
包括以下命名空间:
using AForge.Video;
using AForge.Video.DirectShow;
using AForge.Video.FFMPEG;
using System.Drawing.Drawing2D;
using AForge.Video.VFW;
您可以设置变化的帧速率,按您的方便。
+0
是否拍摄照片或拍摄视频? –
+0
它捕获的视频,但正如你可以在代码中看到有图像被添加在框架中。你可以选择任何图像。 –
+0
VS无法识别“BitmapImage bi = new BitmapImage();” –
-1
相关问题
- 1. html5从ipad摄像头捕获图像
- 2. 从java摄像头捕获图像?
- 3. 从网络摄像头捕获图像
- 4. Visual C摄像头捕获
- 5. 从Java摄像头捕获
- 6. C#WPF - 从DLL捕获摄像头
- 7. 用Ruby捕获摄像头的图像
- 8. C#:从多个(USB)摄像头捕获静止图像
- 9. 从网络摄像头捕捉图像
- 10. 从网络摄像头捕捉图像
- 11. IP摄像头捕获
- 12. 使用C#winform的Windows Mobile 5.0摄像头的图像捕获
- 13. OpenCV从外部摄像头捕获
- 14. 从网络摄像头和商店捕获图像
- 15. 如何从android摄像头捕获原始图像
- 16. 如何检测图像捕获从哪个摄像头php
- 17. iOS:从前置摄像头捕获图像
- 18. 从Android摄像头捕获单张图像的快速方法
- 19. Opencv:从摄像头捕获的图像始终为灰色
- 20. .NET应用程序从PDA摄像头捕获图像
- 21. OpenCV无法从isight摄像头捕获图像
- 22. 防止摄像头在图库中捕获图像
- 23. Android摄像头:捕获图像数据时意图返回null
- 24. 使用图片框从网络摄像头捕捉图像
- 25. 镜像图像从摄像头
- 26. 使用DirectX.Capture捕获网络摄像头截图[VB/C#]
- 27. 从摄像头获取输入opencv C++
- 28. 使用C++(MFC)从网络摄像头捕获视频文件
- 29. C#.net - 网络摄像头图像捕捉
- 30. 在matlab中捕获摄像头图像时出错
对于SO的图书馆建议是无题的,请尝试在网上搜索“C#library webcam capture”。 – CodeCaster
我已经搜索,但找不到教程 –
@ A.Hajeb至少选择一些图书馆,尝试使用它,如果遇到任何困难,请创建一个关于如何使用该特定图书馆的具体问题。 –