【问题标题】:Camera API for a Windows 8 Tablet on Visual Studio Express 2013 (For Windows Desktop)适用于 Visual Studio Express 2013 上的 Windows 8 平板电脑的相机 API(适用于 Windows 桌面)
【发布时间】:2014-04-14 03:55:49
【问题描述】:

我想使用 Visual Studio Express 2013(适用于 Windows 桌面)为我的平板电脑编写程序。平板电脑运行的是 Windows 8.1 Pro。

为了兼容性和易于编程,我想继续在 VS Express 2013 for Windows Desktop 中工作。

我希望我的程序使用设备的相机捕捉功能。我希望这就像使用已经广为人知的库/API 一样简单。但是,到目前为止,我阅读的所有文档和帮助论坛帖子都表明 WIA(Windows Image Acquisition)是用于桌面的库,而 Windows Media Capture 必须用于 Windows 8.1。

有没有更好的办法?

【问题讨论】:

  • 2014-03-12 更新:我正在寻求不同的解决方案。我将尝试建立一个可以在两个平台上运行的网站。这会很困难,因为我的网络开发经验要少得多。我会尽量保持更新,直到我得到满意的修复。

标签: camera visual-studio-2013 desktop windows-8.1 tablet


【解决方案1】:

您需要做的就是指定一个 CaptureElement 和一个按钮来捕获如下所示的图片

    <CaptureElement x:Name="cap1" Height="300" Width="450"/>
    <Button Content="Take a Photo" x:Name="btnCapture" HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch" Click="btnCapture_Click"/>

这是按钮背后的代码:

      private async void btnCapture_Click(object sender, RoutedEventArgs e)
    {
        var _MediaCapture = new MediaCapture();
        await _MediaCapture.InitializeAsync();
        cap1.Source = _MediaCapture;
        await _MediaCapture.StartPreviewAsync();
    }

请记住,您需要使用 Async 和 await 关键字,因为此过程是 Asynchronous 。

【讨论】:

  • 也许我不明白,也许你不明白。在我看来,CaptureElement Class 是 Windows 应用商店应用程序的 Windows API 参考的成员。我无法从运行 Windows 7 的机器上开发 Windows 商店应用程序,因为我无法安装适用于 Windows 的 VS(只有适用于 Windows 桌面的 VSE,它不允许我引用这些库)。 Here 更清楚。我正在寻求使用网站的解决方法。
  • 对于 windows 窗体只有 WIA 库,好吧.. VSE for desktop 是否提供开发 WPF 应用程序的能力?我想这是您可以考虑的另一种选择。很抱歉一开始的问题被误解了。
  • 桌面版 VSE 确实支持 WPF 开发。这是否为我提供了一些 Windows 8.1 和 Windows 7 相互支持的参考资料?
猜你喜欢
  • 2018-07-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多