私は、C#、Kinect、および Emgu CV を含む学校向けのプロジェクトに取り組んでいます。私は C# と Emgu CV の両方にかなり慣れていないので、単純なものが欠けている可能性があります。私がやろうとしているのは、Kinect の画像を処理用の Emgu CV 画像として使用することですが、エラーが発生し続けます。表示されるエラーは、「TypeInitializationException was unhandled」と「The type initializer for 'Emgu.Cv.CVInvoke' throw an exception.」です。
Kinect から画像を取得するために使用しているコードは次のとおりです。
using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
{
if (colorFrame != null)
{
byte[] pixels = new byte[colorFrame.PixelDataLength];
colorFrame.CopyPixelDataTo(pixels);
int stride = colorFrame.Width * 4;
BitmapSource color = BitmapImage.Create(colorFrame.Width, colorFrame.Height,96, 96, PixelFormats.Bgr32, null, pixels, stride);
liveFeed.Source = color;
EmguCVProcessing(color);
}
else
{
return;
}
}
また、BitmapSource を Bitmap に変換するために使用しているコードもいくつか見つけました。
動作しないコードは次のとおりです。
void EmguCVProcessing(BitmapSource bitmap)
{
Bitmap bmp = GetBitmap(bitmap);
Image<Bgr, Byte> imgLiveFeed = new Image<Bgr, Byte>(bmp);
}
私が見つけたものから、これはビットマップを Emgu CV イメージに変換するはずですが、何らかの理由でそうではありません。
もう少し情報:
InnerException: ファイル イメージが有効なマネージド アセンブリであることを確認してください。
InnerException: アセンブリに正しいファイル パスを指定したことを確認してください。
プログラムが異なるバージョンの .NET Framework を使用していると推測されますが、この問題を解決する方法がわかりません。