How to replace kinect interaction input with mouse input?

Can anyone advise me how to replace kinect input to mouse input using OpenNIprocessing? Instead of BlobDetection(hand tracking), I want to switch to mouse tracking. I need to create a trackpad version of this kinect code on this link - Example 2: Kinect Flow.

the code

// import libraries
import processing.opengl.*; // opengl
import SimpleOpenNI.*; // kinect
import blobDetection.*; // blobs

// this is a regular java import so we can use and extend the polygon class (see PolygonBlob)
import java.awt.Polygon;

// declare SimpleOpenNI object
SimpleOpenNI context;
// declare BlobDetection object
BlobDetection theBlobDetection;
// declare custom PolygonBlob object (see class for more info)
PolygonBlob poly = new PolygonBlob();

// PImage to hold incoming imagery and smaller one for blob detection
PImage cam, blobs;
// the kinect’s dimensions to be used later on for calculations
int kinectWidth = 640;
int kinectHeight = 480;
// to center and rescale from 640x480 to higher custom resolutions
float reScale;

// background color
color bgColor;
// three color palettes (artifact from me storing many interesting color palettes as strings in an external data file :wink:
String[] palettes = {

// an array called flow of 2250 Particle objects (see Particle class)
Particle[] flow = new Particle[2250];
// global variables to influence the movement of all particles
float globalX, globalY;

void setup() {
// it’s possible to customize this, for example 1920x1080
size(1280, 720, OPENGL);
// initialize SimpleOpenNI object
context = new SimpleOpenNI(this);
if (!context.enableScene()) {
// if context.enableScene() returns false
// then the Kinect is not working correctly
// make sure the green light is blinking
println(“Kinect not connected!”);
} else {
// mirror the image to be more intuitive
// calculate the reScale value
// currently it’s rescaled to fill the complete width (cuts of top-bottom)
// it’s also possible to fill the complete height (leaves empty sides)
reScale = (float) width / kinectWidth;
// create a smaller blob image for speed and efficiency
blobs = createImage(kinectWidth/3, kinectHeight/3, RGB);
// initialize blob detection object to the blob image dimensions
theBlobDetection = new BlobDetection(blobs.width, blobs.height);

void draw() {
// fading background
fill(bgColor, 65);
rect(0, 0, width, height);
// update the SimpleOpenNI object
// put the image into a PImage
cam = context.sceneImage().get();
// copy the image into the smaller blob image
blobs.copy(cam, 0, 0, cam.width, cam.height, 0, 0, blobs.width, blobs.height);
// blur the blob image
// detect the blobs
// clear the polygon (original functionality)
// create the polygon from the blobs (custom functionality, see class)

void setupFlowfield() {
// set stroke weight (for particle display) to 2.5
// initialize all particles in the flow
for(int i=0; i<flow.length; i++) {
flow[i] = new Particle(i/10000.0);
// set all colors randomly now

void drawFlowfield() {
// center and reScale from Kinect to custom dimensions
translate(0, (height-kinectHeight*reScale)/2);
// set global variables that influence the particle flow’s movement
globalX = noise(frameCount * 0.01) * width/2 + width/4;
globalY = noise(frameCount * 0.005 + 5) * height;
// update and display all particles in the flow
for (Particle p : flow) {
// set the colors randomly every 240th frame

// sets the colors every nth frame
void setRandomColors(int nthFrame) {
if (frameCount % nthFrame == 0) {
// turn a palette into a series of strings
String[] paletteStrings = split(palettes[int(random(palettes.length))], “,”);
// turn strings into colors
color[] colorPalette = new color[paletteStrings.length];
for (int i=0; i<paletteStrings.length; i++) {
colorPalette[i] = int(paletteStrings[i]);
// set background color to first color from palette
bgColor = colorPalette[0];
// set all particle colors randomly to color from palette (excluding first aka background color)
for (int i=0; i<flow.length; i++) {
flow[i].col = colorPalette[int(random(1, colorPalette.length))];

You should ask this on the Processing forum at rather than the OF forum, they’ll probably know more about it than people here.