-1

私は WPF アプリケーションを実行しています。機能の 1 つは、Kinect センサー (Aforge と SDK 1.5 を使用) からビデオ (RGB ストリームのみ) を記録することです。

私のアプリケーションでは、クリックするとビデオ ストリームを avi ファイルに保存するボタンがあります。

参照を追加し、すべての .dll ファイルをプロジェクト フォルダーにコピーしました (他のフォーラムで説明されているように) が、何らかの理由で次のエラーが表示されます。

{"Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.":null}

そのため、内部private void button4_Click(object sender, RoutedEventArgs e)には次のコードがあります。

        int width = 640;
        int height = 480;
        // create instance of video writer
        VideoFileWriter writer = new VideoFileWriter();

        // create new video file
        writer.Open("test.avi", width, height, 25, VideoCodec.MPEG4);

        // create a bitmap to save into the video file
        Bitmap image = new Bitmap (width, height, DrawingColor.PixelFormat.Format24bppRgb);


        for (int i = 0; i < 1000; i++)
        {
            image.SetPixel(i % width, i % height, Color.Red);
            writer.WriteVideoFrame(image);
        }
        writer.Close();
        }

私は本当にあなたの助けに感謝し、RGBストリームを記録する方法にも柔軟に対応できます(別の方法をお勧めする場合)、C#が初めてなので複雑ではない限り

4

1 に答える 1

1

ビデオが赤い理由は、あなたがそれを赤くしているためです

    for (int i = 0; i < 1000; i++)
    {
        image.SetPixel(i % width, i % height, Color.Red);
        writer.WriteVideoFrame(image);
    }

あなたがすべきことはBitmapSource/ WritableBitmap* を変換することです (Kinect のデータをBitmapSourceorで表示していると仮定しますWritableBitmap。次に、そのビットマップをビデオ フレームに追加するだけです。これが役に立てば幸いです!

** を使用している場合は、 にWritableBitmap変換BitmapImageてから、Bitmap *に変換します。

于 2012-08-29T15:59:25.653 に答える