在 WPF 应用程序中从网络摄像头抓取图片?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24652901/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Grab picture from web cam in WPF Application?
提问by Akhilesh Chaturbedi
I am using web cam in WPF application. I am using Expression Encoder for video capture. for video capture I have created Job and its working properly. While I want to get picture with same resolution as video is. for this I am using ffmpeg to extract first frame from video. but quality of image is very low. the priority is that image quality should be best of attached web cam and resolution should be as much as video is.
我在 WPF 应用程序中使用网络摄像头。我正在使用 Expression Encoder 进行视频捕获。对于视频捕获,我创建了 Job 并且它可以正常工作。虽然我想获得与视频分辨率相同的图片。为此,我使用 ffmpeg 从视频中提取第一帧。但图像质量非常低。优先考虑的是图像质量应该是附加的网络摄像头的最佳质量,并且分辨率应该与视频一样多。
Either we have any better option in Expression Encode for taking picture or kindly help me with any alternative.
要么我们在 Expression Encode 中有更好的选择来拍照,要么请帮助我提供任何替代方案。
回答by Sasha Yakobchuk
You can have a look at this control:
你可以看看这个控件:
The control provides the following functionalities:
该控件提供以下功能:
Gets a list of available web camera devices on a system.
Displays a video stream from a web camera device.
Gets the current image being captured.
获取系统上可用网络摄像头设备的列表。
显示来自网络摄像头设备的视频流。
获取当前正在捕获的图像。
Requirements
要求
The WPF version of the control is implemented using .NET Framework 4 Client Profile.
The control uses the VMR-9 renderer filter available since Windows XP SP2.
The control supports both x86 and x64 platform targets.
该控件的 WPF 版本是使用 .NET Framework 4 Client Profile 实现的。
该控件使用自 Windows XP SP2 起可用的 VMR-9 渲染器过滤器。
该控件支持 x86 和 x64 平台目标。
回答by Sheridan
For some reason, accessing images from a web cam is far more complicated then it should be. While I have not used the Expression Encode application, I can provide you with two links to CodePlex, where you can find two different libraries that could help you to solve your problem. Please see the following pages:
出于某种原因,从网络摄像头访问图像比应该复杂得多。虽然我没有使用 Expression Encode 应用程序,但我可以为您提供两个指向 CodePlex 的链接,您可以在其中找到两个可以帮助您解决问题的不同库。请参阅以下页面:
WebCam Library for WinForm and WPF with C# and VB.NET
带有 C# 和 VB.NET 的 WinForm 和 WPF 网络摄像头库
WPF MediaKit - For webcam, DVD and custom video support in WPF
WPF MediaKit - 用于 WPF 中的网络摄像头、DVD 和自定义视频支持
Alternatively, if you're happy with using Expression Encode, then you could take a look at the following links:
或者,如果您对使用 Expression Encode 感到满意,那么您可以查看以下链接:
Extracting still pictures from movie files, with C#
Extract frames from video files – The Code Project – Multimedia
回答by Peter
I would recommend AForge.Net, it works flawless, free and licensed under LGPL v3 license, it also seems to work in both 32 and 64 bit.
我会推荐AForge.Net,它完美无缺,免费并且在 LGPL v3 许可下获得许可,它似乎也适用于 32 位和 64 位。
The only drawback is that you need ~400 kb worth of dlls to get the webcam control.
唯一的缺点是您需要大约 400 kb 的 dll 才能获得网络摄像头控制。