-1

I'm doing a WPF application and one of the functions is to record video (Only RGB stream) from Kinect sensor (using Aforge and SDK 1.5).

In my application, i have a button that when clicked, it should save the video stream into an avi file.

I've added the references and I copied all the .dll files into my projects folder (as was explained on other forums) but for some reason I receive this error:

{"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}

So inside private void button4_Click(object sender, RoutedEventArgs e) is the following code:

        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();
        }

I will really appreciate your help and also im flexible with the way to record RGB stream(if you recommend another way), as long a its not complicated because im new with C#

Ranhiru Jude Cooray
  • 19,542
  • 20
  • 83
  • 128
  • you might want to look at this - http://stackoverflow.com/questions/3179028/mixed-mode-assembly-in-net-4 - in your case one of the assemblies you're referencing is a native/managed mixed assembly and has to be hosted in the same runtime as it was compiled for. – Andras Zoltan Aug 29 '12 at 11:03
  • 1
    [I asked google and it told me what to do](https://www.google.com/search?q=Mixed+mode+assembly+is+built+against+version&oq=Mixed+mode+assembly+is+built+against+version&sugexp=chrome,mod=13&sourceid=chrome&ie=UTF-8) – Renatas M. Aug 29 '12 at 11:03
  • @AndrasZoltan Thanks a lot, it worked. I dont get the error anymore, and i can actually find the video file but its just a bunch of red lines and not the actual RGB stream. Any idea? Thanks mate! – user1632904 Aug 29 '12 at 11:26
  • 3
    Considering all you write to the image is red, and you're not writing every pixel or any sort of pattern, that's exactly what you should expect. – ssube Aug 29 '12 at 12:24

1 Answers1

1

The reason the video is red is because you are turning it red with

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

What you should do is convert the BitmapSource/WritableBitmap* (assuming you are displaying Kinect's data with a BitmapSource or WritableBitmap Then you can just add that bitmap to your Video frame. Hope this helps!

**If you are using a WritableBitmap, convert it to a BitmapImage, then convert that to a Bitmap*

Community
  • 1
  • 1
Liam McInroy
  • 4,339
  • 5
  • 32
  • 53
  • LemurThankyou for your reply. Ok it make sense to me now. I've only one problem that I cant find the SetSource nor the SaveJpeg methods although I include windows.meda and windows.media.imaging. Sorry if i seem a little dumb but I'm really just a novice with programming and C# – user1632904 Aug 30 '12 at 22:06