c# - Azure Kinect 传感器 SDK - 用于图像捕获的 C# 包装器缺少“缓冲区”?
问题描述
我正在观看“Azure Kinect 开发简介 - BRK1001”的视频。
https://www.youtube.com/watch?v=HzeYb00eQRI
当时正在编写代码并注意到该属性在演示文稿Buffer
中不可用Microsoft.Azure.Sensor.Image
但正在被引用。如何Buffer
在我的代码中使用?
我已经安装了 SDK 1.2.0-alpha.10 Microsoft 视频来自 2019 年 5 月 7 日,所以它不是那么旧。
解决方案
C# wrapper的生产版本于上周刚刚发布。我们即将发布可以解决您的问题的示例代码,但这是您现在正在寻找的:
private async void Window_Loaded(object sender, RoutedEventArgs e) { int count = 0;
while (running)
{
using (Image transformedDepth = new Image(ImageFormat.Depth16, colorWidth, colorHeight, colorWidth * sizeof(UInt16)))
using (Capture capture = await Task.Run(() => { return this.kinect.GetCapture(); }))
{
count++;
this.transform.DepthImageToColorCamera(capture, transformedDepth);
this.bitmap.Lock();
var color = capture.Color;
var region = new Int32Rect(0, 0, color.WidthPixels, color.HeightPixels);
unsafe
{
using (var pin = color.Memory.Pin())
{
this.bitmap.WritePixels(region, (IntPtr)pin.Pointer, (int)color.Size, color.StrideBytes);
}
if (boundingBox != null)
{
int y = (boundingBox.Y + boundingBox.H / 2);
int x = (boundingBox.X + boundingBox.W / 2);
this.StatusText = "The person is:" + transformedDepth.GetPixel<ushort>(y, x) + "mm away";
}
}
this.bitmap.AddDirtyRect(region);
this.bitmap.Unlock();
if (count % 30 == 0)
{
var stream = StreamFromBitmapSource(this.bitmap);
_ = computerVision.AnalyzeImageInStreamAsync(stream, MainWindow.features).ContinueWith((Task<ImageAnalysis> analysis) =>
{
try
{
foreach (var item in analysis.Result.Objects)
{
if (item.ObjectProperty == "person")
{
this.boundingBox = item.Rectangle;
}
}
}
catch (System.Exception ex)
{
this.StatusText = ex.ToString();
}
}, TaskScheduler.FromCurrentSynchronizationContext());
}
}
}
}
推荐阅读
- html - 如何使用边框底部移动下划线以使其看起来像使用框阴影插图的下划线?
- php - 如何远程向kafka发送消息
- c# - 如何进行适当的深拷贝?
- c# - 如何在 C#.net 中使用带有 .pem 文件的 SFTP?
- python - 打开 PDF 文件并按下 page down 键 - Robot Framework
- azure-devops - Azure DevOps Pipelines Release Copy Files 步骤“该进程无法访问该文件,因为它正被另一个进程使用”
- angular - 带 DebounceTime 的 SwitchMap
- sql - 如何在对角线上对表进行 SQL 求和?
- c++ - 在 Visual Studio Code 中包含自定义 C++ 库的问题
- visual-studio-2017 - VB6通过Visual Studio Attached Process VS2017及以上调试