c# - 在 C# 控制台应用程序中使用 Windows 8 API (VideoCaptureDevices)

标签 c# video-capture windows-8.1

环顾四周,我找不到任何解决方案。

  • 目标:让我的 Windows 8.1 平板电脑上的相机闪光灯 LED 闪烁。使用Windows 8.1开发和VS2013。
  • InitializeAsync 方法允许应用程序使用默认设置初始化摄像头和麦克风
  • 我将该应用程序构建为 Windows 应用商店应用程序,并且运行完美。
  • 我需要该文件是可执行文件,我需要将其转换为控制台应用程序
  • 当我执行 mc.InitializeAsync 时出现以下错误“错误 1 ​​'await' 要求类型 'Windows.Foundation.IAsyncAction' 具有合适的 GetAwaiter 方法。您是否缺少 'System' 的 using 指令?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”的引用才能使其工作。此处有关来自非地铁应用程序的异步调用的更多信息: http://www.wintellect.com/blogs/jeffreyr/using-the-windows-runtime-from-a-non-metro-application

关于c# - 在 C# 控制台应用程序中使用 Windows 8 API (VideoCaptureDevices),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18877943/

相关文章:

c++ - 使用 IAMCameraControl::Set() 在 Windows Mobile 设备上设置缩放

c# - 如何从 Windows Media Server 2008 捕获实时流

c# - 以编程方式单击 TreeView 中的节点?

c# - Linq to Sql 中的可空 Guid 产生意外结果

c# - 将数据表自动增量列与数据库同步

c# - Interaction.Behaviors 不适用于按钮内容

c# - VS 2013 c# sqlite 构建失败 App Certification Kit 来自 msvcr100.dll 的高风险

c# - 获取登录用户的 AppData\Local 文件夹

java - 是否可以流式传输 ITU-R BT.656 格式的视频?

linux - 回溯5无法启动