gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 13:35:21 27 4
gpt4 key购买 nike

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

  • 目标:让我的 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com