C#通用Windows应用程序检测来自ip camera的面部

时间:2018-04-04 04:59:49

标签: c# uwp camera ip

我正在使用c#和XAML开发通用Windows应用程序。我的要求是使用IP摄像头来检测Face。 我参考了https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/CameraFaceDetection。但我想将集成网络摄像头替换为IP摄像头。现在我不知道如何连接到IP Camera,所以任何人都给我一些建议来解决它。

1 个答案:

答案 0 :(得分:0)

使用Package.appxmanifest文件中的相应功能配置

  <Capabilities>
    <Capability Name="internetClient" />
    <Capability Name="privateNetworkClientServer" />
    <Capability Name="internetClientServer" />
    <DeviceCapability Name="webcam" />
  </Capabilities>

您可以使用以下代码获取ip camera数据

Windows.Storage.Streams.IRandomAccessStream random = 
    await Windows.Storage.Streams.RandomAccessStreamReference.CreateFromUri(new Uri("your device uri")).OpenReadAsync();

Windows.Graphics.Imaging.BitmapDecoder decoder = await Windows.Graphics.Imaging.BitmapDecoder.CreateAsync(random);
Windows.Graphics.Imaging.PixelDataProvider pixelData = await decoder.GetPixelDataAsync();

byte[] bytes = pixelData.DetachPixelData();

请注意:您应该在上面的代码中咨询或找到your device uri的相机制造商。