Prototype 2#

I found my experimenting to be a good ground point, so I began looking into ways that I could pick up users when they entered into camera shot.

The OpenNI library will do a lot of the work for me when identify moving objects in a scene. The scene analyser does this, when turn on.

context.enableScene( );

The same needs to be applied to the depth image in order for the scene to be analysed.

context.enableDepth( );

So that I can access the labelling data for each object in the foreground, i need to add in to the draw function

int[ ] map = context.sceneMap( )

This in turn relays an array of integers for each pixel. The value in each array is an integer that will label the various objects in my scene. If the pixel is analysed as being part of my background, it is ‘0’, otherwise it will be assigned to any other moving object that is picked up.

This code below is what I’ve used to identify if the camera has found someone. It will print ‘found person’ whenever someone has been picked up in the scene.

void draw()

{

context.update( );

image(context.sceneImage( ), 0, 0);

int[] map = context.sceneMap();

boolean foundPerson = false;

for (int i=0; i<map.length; i++){

if(map[i] > 0) {

foundPerson = true; } } if (foundPerson) println(“Found Person”);

}

With all the code this was the final result.

tracking

 

Leave a comment