Wednesday, June 15, 2011

Multiple OpenNI Generators

Anonymous asked in this comment here how you could get both depth and rgb image synchronously.

I've made a quick example, you can download it here. I haven't had time to test it, so I'd be happy to receive feedback if it works for you. If it does, I will add those two classes in the next change set.

5 comments:

  1. Cool that you implemented this so fast. I am going to test it and give you feedback. :)

    Thank you!

    ReplyDelete
  2. May I contact you via Email because I still have some questions regarding the code...

    Is this your Email (info at candescent dot ch) or do you have another one???

    ReplyDelete
  3. Ok I try to ask here in the comments (even though per Email the indentation of code would work better, and I wouldn't be limited to short comments)...

    Is MultiGeneratedDataSource.cs similar to RGBPointerDataSource?

    Then it should have in the method InternalRun() also a call to this.OnNewDataAvailable(this.CurrentValue); after setting this.CurrentValue. True?

    If I would be in MainForm.cs and do analog to
    this.SetImageDataSource(new RGBImageSource(new RGBPointerDataSource(this.facade.GetImageGenerator()) how should the call look like?

    Let's say I would write my new DataSource and call it like this
    this.SetImageDataSource(new MyDataSource(new MultiGeneratorDataSource(context,this.facade.GetImageGenerator(),this.facade.GetDepthGenerator()). The question is who is context?


    MyDataSource class should inherit from DataSourceProcessor? And can I do then my computations in the protected override unsafe Bitmap Process(IntPtr sourceData) for instance by calling this.CurrentValue.ImageData.RgbPointer or this.CurrentValue.ImageData.DepthPointer?

    ReplyDelete
  4. Yes, you can contact me via info@candescent.ch

    Context is a OpenNI class (xn.Context), it is also available on the OpenNIFacade object (.Context).

    Yes you're right, the MultiGeneratorDataSource should call OnNewDataAvailable.

    Well, the question is, what you want to do with the rgb and depth image. Combine it into a single image? Then you should write a DataSource that does this and returns this combined image. This DataSource could inherit from DataSourceProcessor, yes.

    Or do you just want to display both images at the same time? Then you could simply add two VideoControls and give each one its own datasource (RGBImage and DepthImage) without writing any new code.

    ReplyDelete
  5. As I wrote via Email I am looking for a combination of both. One image source for the video control should have a combination of both images and two other video controls the original images (rgb and depth). How can I implement the last Point with RGBImage and DepthImage without writing any new code?

    ReplyDelete