シーンから深度情報を抽出しており、ポイントの X、Y、Z 位置をファイルに書き込みたいと考えています。
using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
{
if (depthFrame != null)
{
frameWidth = depthFrame.Width;
frameHeight = depthFrame.Height;
depthFrame.CopyDepthImagePixelDataTo(this.depthPixels); //Per essere visualizzati nella finestra
depthFrame.CopyPixelDataTo(this.shortDepth); //Per essere scritti nel file
mapper.MapDepthFrameToSkeletonFrame(DepthImageFormat.Resolution640x480Fps30, depthPixels, this.realPoints);
minDepth = depthFrame.MinDepth;
maxDepth = depthFrame.MaxDepth;
colorizer.ConvertDepthFrame(this.depthPixels, minDepth, maxDepth, this.depthTreatment, this.depthFrame32);
this.writableBitmap.WritePixels(
new Int32Rect(0, 0, frameWidth, frameHeight),
this.depthFrame32,
frameWidth * Bgr32BytesPerPixel,
0);
this.kinectDepthImage.Source = this.writableBitmap;
if (this.record)
{
using (StreamWriter writer = new StreamWriter(File.Open(mypath,FileMode.Append)))
{
writer.Write(realPoints);
writer.WriteLine();
}
}
}
}
ここで、SkeletonPoint 変数 (realPoints) を次のようにファイルに書き込みます。
- 最初の行のすべての realPoints X
- 2 行目のすべての realPoints Y
- 3 行目のすべての realPoints Z
したがって、フレームごとに (640*480) の要素を持つ 3 つの行ができます。
私の質問:
- この方法でデータを書き込むにはどうすればよいですか?
- Stream Writer は 30 fps で動作するのに十分効率的ですか?