Search code examples
macosprocessingkinect

Processing: save color and depth images


I just started working with Processing, because I need to get a sequence of images, color and depth. When I save does images while drawing, so for each image I get I save it. I have around 2fps. Is there a way to improve this?

My thought was to store the image in an array list. I thought there is a function setup() so there would be also a function shutdown() or something. So When i hit the Esc button or close the window which is getting cold. Like a decompiler. Where I can run a loop trough that lists and save them. But I don't find such a function.

I am working on a MacBook Air (2013)


Solution

  • If you use OpenNI/SimpleOpenNI I recommend a nicer option: use the the .oni format (which stores both depth and rgb streams). All you have to do is:

    1. Record to an .oni file (fast/realtime)
    2. Read the depth/color streams from the recorded .oni streams when you need to.

    To record to an .oni file you've got two options:

    1. Use the Examples > Contributed Libraries > SimpleOpenNI > OpenNI > RecorderPlay sketch to record (some explanations at the bottom of this answer)
    2. Use OpenNI SDK's NiViewer utility which can also save/load .oni files. (You can easily install this using homebrew: brew install homebrew/science/openni2. The path in this case will be something like /usr/local/Cellar/openni2/2.2.0.33/share/openni2/tools/NiViewer)

    Once you have your .oni file, you can easily read it/play it back at different rate and access depth/rgb streams to save to disk.

    Regarding your existing program The frame rate drops because in the same thread it's encoding and writing two images to disk per frame. You can improve this by:

    1. saving to an uncompressed format (like tiff)
    2. threading the image save operation (see the bottom of this answer for some ideas)