You are on page 1of 20

import processing.serial.

*; // including serial library


import hypermedia.video.*; // OpenCV library
import netscape.javascript.*;// JAvascript call
void draw() //displays the items on the loaded GUI
{
sensorvalue.update(); // continouos update from kinect
sensorvalue.update(sessionManager); // points are registered in the NITE track
ing library
image(sensorvalue.rgbImage(),0, 0);// display quality in RGB video
if (pointcontrolmarker)
{
circlemarker(); //displays the point
pointcontrolmapping();//calculation of control regions
}
if (serial)// serial communication loop
{
arduinocomm();
}
}
boolean pointcontrolmarker= false;
PVector vectora = new PVector();// major vector used for calculation of regions
PVector vectorb = new PVector();//minor vector used for display
float leftscreen = width;
float bottomscreen = height;
int SPEED1; // Variable used for left and right movements
int SPEED2; // Variable used for determining forward or reverse motion
int SPEED3; // Variable used for PWM
float
float
float
float

regiona;
regionb;
regionc;
regiond;

//
//
//
//

Point
Point
store
store

control width region


control height region
values for region a
values for region b

void setup() {

sensorvalue = new SimpleOpenNI(this);


sensorvalue.setMirror(true); // to mirror the video of the kinect sensor in orde
r for the user to track real time
sensorvalue.enableDepth(); // depth map activation
sensorvalue.enableRGB(); // rgb camera activation
sensorvalue.enableGesture(); // gesture call out as a package of NITE even thoug
h not used

sensorvalue.enableHands(); // gesture call out as package of NITE


sessionManager = sensorvalue.createSessionManager("Click","Wave"); // Push scree
n to enable point tracking
pointControl = new XnVPointControl(); //registry for depth map
pointControl.RegisterPointCreate(this); // point movement create
pointControl.RegisterPointDestroy(this); // point movement destroyed
pointControl.RegisterPointUpdate(this); // recreate point
sessionManager.AddListener(pointControl); // sessionmanager registers the points
size(sensorvalue.rgbWidth(), sensorvalue.rgbHeight()); //setting the size of the
screen to match the OpenCV GUI
regiond = int(map(regionb, -height/2, height/2, -400,390 ));//map region from
left to right of screen
if
(regiond>0 && regiond>150)
else if (regiond<0 && regiond<-150)
else
if
(regiond>200 && regiond<300)
if
(regiond>300)
if
PWM
if
e PWM

{
{
{
{
{

SPEED2=1; }//forward movement


SPEED2=2; }//reverse movement
SPEED2=0; } //no movement
SPEED3=90;}//low speed PWM
SPEED3=120;}//high speed PWM

(regiond<-200 && regiond>-300)

SPEED3=90;}//low speed reverse

(regiond<-300)

SPEED3=120;}//high speed revers

}
void circlemarker()//Creates the point to be viewed on screen in 2 dimension
{
stroke(0, 25, 90);// displays the point
strokeWeight(25);//size of point
sensorvalue.convertRealWorldToProjective(vectorb, vectora);//convert from stro
ke value to display on vector
point(vectora.x, vectora.y);//displayed in 2 dimension with x and y axis
}
boolean serial = false; //declaration for loop to open
void arduinocomm() {
serialcommunication.write('Q');//charactervalue used to indicate program
serialcommunication.write(SPEED1);//send direction to arduino
serialcommunication.write(SPEED2);//sends forward or reverse command to arduin
o
serialcommunication.write(SPEED3);//sends PWM speed control to Arduino
}

import SimpleOpenNI.*;

SimpleOpenNI sensorvalue;

XnVSessionManager sessionManager;

XnVPointControl pointControl;

Serial serialcommunication;

You might also like