MediaCapture Windows 8的桌面应用程序 - 不能得到它的工作 [英] MediaCapture Windows 8 Desktop Application- Can't get it work

查看:261
本文介绍了MediaCapture Windows 8的桌面应用程序 - 不能得到它的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现通过此API图像捕捉,我需要通过桌面应用程序来实施

I'm trying to implement an image capture via this API, and I need to implement in via desktop application.

现在的问题是,当我将图像保存到一个文件( CapturePhotoToStorageFileAsync )我得到一个黑暗的画面(几乎是黑色的),或者我得到零大小的文件。

The problem is that when I save the image into a file (with CapturePhotoToStorageFileAsync) I get a dark picture (almost black), or I get zero size file.

我的code是很简单的,但:

My code is very simple though:

MediaCapture = new MediaCapture();
await mediaCapture.InitializeAsync();

Windows.Storage.StorageFile photoStorageFile;
String PHOTO_FILE_NAME = "photo.jpg";
photoStorageFile = await Windows.Storage.KnownFolders.PicturesLibrary.CreateFileAsync(PHOTO_FILE_NAME, Windows.Storage.CreationCollisionOption.GenerateUniqueName);
ImageEncodingProperties imageProperties = ImageEncodingProperties.CreateJpeg();
await mediaCapture.CapturePhotoToStorageFileAsync(imageProperties, photoStorageFile);

我读到它另一个线程: <一href="http://stackoverflow.com/questions/28301513/captured-photos-are-black-when-using-mediacapture-on-windows-phone-8-1">Captured照片是黑色的Windows Phone 8.1

I read another thread about it: Captured photos are black when using MediaCapture on Windows Phone 8.1

问题是, MediaCapture.Start previewAsync 引发异常意外的错误已请求的操作出错,我想其中的原因是我没有MediaElement的(再次,桌面)。

The problem is that MediaCapture.StartPreviewAsync raised an exception "An unexpected error has occured in the operation requested", and I guess the reason for that is the MediaElement which I don't have (again, desktop).

我还会高兴地发现工作的例子,当我搜索,我没有找到实现MediaCapture桌面应用程序的任何实际样品,我看到一篇文章,但没有附加code: <一href="http://blogs.msdn.com/b/eternalcoding/archive/2013/10/29/how-to-use-specific-winrt-api-from-desktop-apps-capturing-a-photo-using-your-webcam-into-a-wpf-app.aspx" rel="nofollow">http://blogs.msdn.com/b/eternalcoding/archive/2013/10/29/how-to-use-specific-winrt-api-from-desktop-apps-capturing-a-photo-using-your-webcam-into-a-wpf-app.aspx

I'll also glad to find a working example, when I searched, I didn't find any real sample to implement MediaCapture on desktop application, I saw an article but without attached code: http://blogs.msdn.com/b/eternalcoding/archive/2013/10/29/how-to-use-specific-winrt-api-from-desktop-apps-capturing-a-photo-using-your-webcam-into-a-wpf-app.aspx

我还发现,其他人还问到的样品,但没有真正的答案...

I also found that others also asked about a sample, but with no real answer...

我怎样才能得到一个工作样本是什么?

How can I get a working sample for that?

推荐答案

获得 MediaCapture 来preVIEW在桌面上的摄像头视频应用服务是不平凡的。我不知道所有的作品都在那里,所以我把一些code GitHub上尝试一下,它似乎工作确定。

Getting MediaCapture to preview the camera video in Desktop apps is not trivial. I wasn't sure all the pieces were there so I put together some code on GitHub to try it out and it seems to work ok.

https://github.com/mmaitre314/MediaCaptureWPF

警告:建设MediaCapture / WPF互操作所需的一些本土code(C ++ / CLI),因此应用程序需要被构建为x86或x64,而不是值为anycpu

One caveat: building the MediaCapture/WPF interop required some native code (C++/CLI), so the app needs to be built as either x86 or x64, but not AnyCPU.

这篇关于MediaCapture Windows 8的桌面应用程序 - 不能得到它的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆