使用Windows 8 API,在C#控制台应用程序中调用(VideoCaptureDevices)。

3

我找了很多,但都没有找到解决方案。

  • 目标:在我的Windows 8.1平板电脑上闪烁相机闪光灯LED。使用Windows 8.1进行开发和VS2013。
  • InitializeAsync方法允许应用程序使用默认设置初始化相机和麦克风
  • 我将应用程序构建为Windows Store应用程序,它运行得非常流畅。
  • 我需要将文件作为可执行文件,并将其转换为控制台应用程序
  • 当我执行mc.InitializeAsync时,会出现以下错误:“Error 1 'await' 要求类型 'Windows.Foundation.IAsyncAction' 具有合适的 GetAwaiter 方法。你是否缺少了“System”命名空间的使用指令? c:\users\levi\documents\visual studio 2013\projects\ledblinkerconsole\ledblinkerconsole\torch.cs 16 14 LEDBlinkerConsole
  • 我不知道如何通过控制台应用程序初始化相机
  • 任何其他闪烁LED闪光灯的方法都非常感激。虽然我不能访问内存位置以使用C ++实现闪烁。

谢谢大家!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Media.Devices;
using Windows.Media.Capture;

namespace LEDBlinkerConsole
{
    class Torch
    {
        public async static void BlinkLED()
        {
            MediaCapture mc = new MediaCapture();
            await mc.InitializeAsync();

            Console.WriteLine("Please type \"flash\" to flash the LED\n");
            string consInput = Console.ReadLine();

            if (consInput.ToUpper() == "FLASH")
            {
                if (mc.VideoDeviceController.TorchControl.Supported == true)
                {
                    mc.VideoDeviceController.TorchControl.Enabled = true;
                    mc.VideoDeviceController.TorchControl.PowerPercent = 100;
                }
            }
        }
    }
}

我解决了。我引用了“System.Runtime”,但我还需要引用“System.Runtime.Windowsruntime”。为了使其工作,我必须删除对“System.Runtime”的引用。有关非 Metro 应用程序中异步调用的更多信息,请参见此处:http://www.wintellect.com/blogs/jeffreyr/using-the-windows-runtime-from-a-non-metro-application - Levi Fuller
1个回答

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接