Quantcast
Channel: Kinect - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 530

How to put a background that changes with time with kinect ?

$
0
0

Hello, Here is my code, I would want that the background is evolutionary in time: that he(it) varies of colors. You could help us we are amateur and begin with processing.

Thank you in advance.

import SimpleOpenNI.*; import java.util.*;

SimpleOpenNI context;

int blob_array[]; int userCurID; int cont_length = 640*480; String[] sampletext = { "lu", "ma" , "me", "ve", "sa", "di", "week", "end" , "b", "c", "le" }; // sample random text

void setup(){

size(640, 480); context = new SimpleOpenNI(this); context.setMirror(true); context.enableDepth(); context.enableUser();

blob_array=new int[cont_length]; }

void draw() {

background(-1); context.update(); int[] depthValues = context.depthMap(); int[] userMap =null; int userCount = context.getNumberOfUsers(); if (userCount > 0) { userMap = context.userMap();

}

loadPixels(); background(255,260,150); for (int y=0; y<context.depthHeight(); y+=35) { for (int x=0; x<context.depthWidth(); x+=35) { int index = x + y * context.depthWidth(); if (userMap != null && userMap[index] > 0) {
userCurID = userMap[index];
blob_array[index] = 255; fill(150,200,30); text(sampletext[int(random(0,10))],x,y); // put your sample random text

      }
      else {
                blob_array[index]=0;


      }
    }
  }

}


Viewing all articles
Browse latest Browse all 530

Trending Articles