关闭网络摄像头闪光灯地铁应用程序C#

关闭网络摄像头闪光灯地铁应用程序C#,c#,windows-8,microsoft-metro,.net-4.5,C#,Windows 8,Microsoft Metro,.net 4.5,如果我错了,请道歉,我正在使用C#和XAML为Windows 8开发metro应用程序,我的应用程序能够捕获二维码图像,将其保存在图片库中,解码二维码图像(我使用XZing.Net库解码)并显示二维码图像中编码的内容。 如果我用手指挡住网络摄像头闪光灯拍摄图像,一切都正常,但如果拍摄图像后闪光灯打开,XZing.Net无法解码。是否有任何方法可以使用代码关闭闪光灯。请检查下面的代码 try { MediaCapture m_mediaCaptureMgr = new MediaCaptur

如果我错了,请道歉,我正在使用C#和XAML为Windows 8开发metro应用程序,我的应用程序能够捕获二维码图像,将其保存在图片库中,解码二维码图像(我使用XZing.Net库解码)并显示二维码图像中编码的内容。 如果我用手指挡住网络摄像头闪光灯拍摄图像,一切都正常,但如果拍摄图像后闪光灯打开,XZing.Net无法解码。是否有任何方法可以使用代码关闭闪光灯。请检查下面的代码

try
{
   MediaCapture m_mediaCaptureMgr = new MediaCapture();
   await m_mediaCaptureMgr.InitializeAsync();
  qrCameraElement.Source = m_mediaCaptureMgr;
  await m_mediaCaptureMgr.StartPreviewAsync();
}
catch(Exception)
{
}
“qrCameraElement”是CaptureElement的实例

在捕获按钮上单击

StorageFile m_photoStorageFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("QRImage.png", CreationCollisionOption.ReplaceExisting);
ImageEncodingProperties imageProperties = ImageEncodingProperties.CreatePng();
await m_mediaCaptureMgr.ClearEffectsAsync(MediaStreamType.Photo);
await m_mediaCaptureMgr.CapturePhotoToStorageFileAsync(imageProperties, m_photoStorageFile);

StorageFile file = await ApplicationData.Current.LocalFolder.GetFileAsync("QRImage.png");

try
{
       using (IRandomAccessStream photoStream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
     WriteableBitmap writeableBitmap = await BitmapFactory.New(1, 1).FromStream(photoStream);
                            writeableBitmap.SetSource(photoStream);
                            var barcodeReader = new BarcodeReader
                            {
                                PossibleFormats = new List<BarcodeFormat> { BarcodeFormat.QR_CODE },
                                TryHarder = true,
                                AutoRotate = true
                            };
                            var result = barcodeReader.Decode(writeableBitmap);
                            if(result != null)
                            {
                                //Do something
                            }
                            else 
                            {
                               //Display message as unable to read QR image
                            }
    }
    }
    catch(Exception e)
{
    Console.WriteLine(e.Message);
}
StorageFile m_photoStorageFile=wait ApplicationData.Current.LocalFolder.CreateFileAsync(“QRImage.png”,CreationCollisionOption.ReplaceExisting);
ImageEncodingProperties imageProperties=ImageEncodingProperties.CreatePng();
等待m_mediaCaptureMgr.ClearEffectsAsync(MediaStreamType.Photo);
等待m_mediaCaptureMgr.CapturePhotoToStorageFileAsync(imageProperties,m_photoStorageFile);
StorageFile file=wait ApplicationData.Current.LocalFolder.GetFileAsync(“QRImage.png”);
尝试
{
使用(irandomaccesstream photoStream=await file.OpenAsync(Windows.Storage.FileAccessMode.Read))
{
WriteableBitmap WriteableBitmap=等待BitmapFactory.New(1,1).FromStream(photoStream);
writeableBitmap.SetSource(photoStream);
var barcodereder=新的条形码阅读器
{
可能格式=新列表{BarcodeFormat.QR_CODE},
TryHarder=true,
自动旋转=真
};
var结果=条形码阅读器.Decode(writeableBitmap);
如果(结果!=null)
{
//做点什么
}
其他的
{
//将消息显示为无法读取QR图像
}
}
}
捕获(例外e)
{
控制台写入线(e.Message);
}

当使用网络摄像头闪存时,我得到的
结果
为空。请帮帮我。

你在哪里检查结果?你有没有试过放一个
Console.WriteLine(e.Message)
在您的catch语句中(其中
e
是例外)?好的,安迪,我在检查“结果”的地方添加了代码,我希望您理解我的问题,基本上我需要在拍摄图像之前关闭网络摄像头闪光灯(LED)(因为使用闪光灯时,我得到的“结果”为空).你能帮我一下吗..我现在理解你了-我找不到
解码
方法的任何文档,但我收集到,如果找不到QR图像,则返回null,如果闪光灯使QR图像模糊,则不会返回null。您使用的是什么网络摄像头?。。。问题是如果没有严重的黑客攻击,可能无法控制此功能,因为它可能被用于恶意目的。您是否尝试过使用不同的摄像头?