keyboard and serial port crashing Processing with simpleOpenNI and Kinnect Camera
in
Integration and Hardware
•
4 months ago
Hi guys,
I really need your help because my keyboard and my serial port connection is crashing mostly after around 20 - 30 minutes.
Iam actually working on a interactive sound light isntallation which shall detects movements/ the triggering of certain areas in a 3d space
and put surround sound out over Max MSP (OSC Connection).
Max MSP controlls the speaker system and pushes over a usb-r232 cable information to light interface.
- on Mac 10.68
- I use Processing 2.07b with a kinnect kamera
- Max MSP 6
- usb to r232 interface / serial connection.
MY PROBLEM:
mostly after half an hour,
- the keyboard of the macbook is not working anymore
- also the USB-R232 stops working.
Mainly the disfunction of the USB-R232 is my problem,
because then the installation doesn't work !!!
but I guess both are serial interfaces, so there is ONE common REASON for the problem.
I can ensure to about almost 95 % that the errors come from processing ...
Do someone know the problem, a solution?
In the attachement a small patch is sent. SO please have a view on it :-)
Would make me happy. Thanks
LUBOSPATCHOS3.pde
HOTPOINT.pde
I really need your help because my keyboard and my serial port connection is crashing mostly after around 20 - 30 minutes.
Iam actually working on a interactive sound light isntallation which shall detects movements/ the triggering of certain areas in a 3d space
and put surround sound out over Max MSP (OSC Connection).
Max MSP controlls the speaker system and pushes over a usb-r232 cable information to light interface.
- on Mac 10.68
- I use Processing 2.07b with a kinnect kamera
- Max MSP 6
- usb to r232 interface / serial connection.
MY PROBLEM:
mostly after half an hour,
- the keyboard of the macbook is not working anymore
- also the USB-R232 stops working.
Mainly the disfunction of the USB-R232 is my problem,
because then the installation doesn't work !!!
but I guess both are serial interfaces, so there is ONE common REASON for the problem.
I can ensure to about almost 95 % that the errors come from processing ...
Do someone know the problem, a solution?
In the attachement a small patch is sent. SO please have a view on it :-)
Would make me happy. Thanks
LUBOSPATCHOS3.pde
- //überall, wo import davorsteht werden libraries importiert. Diese müsst ihr euch herunterladen und installieren
import processing.opengl.*;
import SimpleOpenNI.*;
import ddf.minim.*;
a
import oscP5.*;
import netP5.*;
SimpleOpenNI kinect;
OscP5 oscP5;
NetAddress myRemoteLocation;
float rotation = 0;
// two AudioPlayer objects this time
Minim minim;
AudioPlayer kick;
AudioPlayer snare;
// declare our two hotpoint objects
Hotpoint currentHotpoint;
Hotpoint[] hotpoints;
float s = 1;
String[] textFile;
String[] hotpointInfo;
PFont f;
int dX=0;
int dY=0;
int dZ=0;
int dSize=500;
void setup() {
size(1024, 768, OPENGL);
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
kinect.enableRGB();
// start oscP5, telling it to listen for incoming messages at port 5001 */
oscP5 = new OscP5(this, 5001);
// set the remote location to be the localhost on port 5001
myRemoteLocation = new NetAddress("127.0.0.1", 5002);
textFile = loadStrings("pos.txt");
hotpoints = new Hotpoint[textFile.length-2];
for (int i=2; i < textFile.length; i++) {
hotpointInfo = split(textFile[i], ',');
currentHotpoint = new Hotpoint(int(hotpointInfo[0]), int(hotpointInfo[1]), int(hotpointInfo[2]), int(hotpointInfo[3]),i-2);
hotpoints[i-2] = currentHotpoint;
}
}
void draw() {
background(0);
kinect.update();
translate(width/2, height/2, -1000);
rotateX(radians(180));
translate(0, 0, 1400);
rotateY(radians(map(mouseX, 0, width, -180, 180)));
translate(0, 0, s*-1000);
scale(s);
stroke(255);
PVector[] depthPoints = kinect.depthMapRealWorld();
for (int i = 0; i < depthPoints.length; i+=10) {
PVector currentPoint = depthPoints[i];
// have each hotpoint check to see
// if it includes the currentPoint
for (int j=0; j < hotpoints.length; j++) {
hotpoints[j].check(currentPoint);
}
point(currentPoint.x, currentPoint.y, currentPoint.z);
}
for (int i=0; i < hotpoints.length; i++) {
if (hotpoints[i].isHit()) {
OscMessage myMessage = new OscMessage(Integer.toString(i));
oscP5.send(myMessage, myRemoteLocation);
}
if (hotpoints[i].isLeft()) {
OscMessage myMessage = new OscMessage(Integer.toString(i));
oscP5.send(myMessage, myRemoteLocation);
}
}
// display each hotpoint
// and clear its points
for (int i=0; i < hotpoints.length; i++) {
hotpoints[i].draw();
hotpoints[i].clear();
}
// Nicht f[r Endversion !!!!
/* pushMatrix();
translate(dX, dY, dZ);
color fillColor = color(2, 5, 200);
fill(red(fillColor), green(fillColor), blue(fillColor), 255);
stroke(red(fillColor), green(fillColor), blue(fillColor), 255);
box(dSize);
popMatrix();*/
}
void stop()
{
// make sure to close
// both AudioPlayer objects
super.stop();
}
void keyPressed() {
if (keyCode == 38) {
s = s + 0.01;
}
if (keyCode == 40) {
s = s - 0.01;
}
if(keyCode == 87)
dY+=200;
if(keyCode == 83)
dY-=200;
if(keyCode == 65)
dX-=200;
if(keyCode == 68)
dX+=200;
if(keyCode == 81)
dZ+=200;
if(keyCode == 69)
dZ-=200;
if(keyCode == 90)
dSize-=50;
if(keyCode == 88)
dSize+=50;
if(dSize<0)
dSize=0;
if(keyCode == 10)
{
print("aktuelle Position X: ");
print(dX);
print(" Y: ");
print(dY);
print(" Z: ");
print(dZ);
print(" Groesse: ");
println(dSize);
}
// println(keyCode);
}
HOTPOINT.pde
- class Hotpoint {
PVector center;
color fillColor;
color strokeColor;
int size;
int pointsIncluded;
int lastPointsIncluded;
int maxPoints;
boolean wasJustHit;
int threshold;
int id;
Hotpoint(float centerX, float centerY, float centerZ, int boxSize, int boxId) {
center = new PVector(centerX, centerY, centerZ);
size = boxSize;
pointsIncluded = 0;
lastPointsIncluded = 0;
maxPoints = 1000;
threshold = 0;
id=boxId;
if(boxId==0)
fillColor = strokeColor = color(218,0,0);
else if(boxId==1)
fillColor = strokeColor = color(0,218,0);
else if(boxId==2)
fillColor = strokeColor = color(0,0,218);
else if(boxId==3)
fillColor = strokeColor = color(240,255,0);
else if(boxId==4)
fillColor = strokeColor = color(222,20,177);
else if(boxId==5)
fillColor = strokeColor = color(20,222,144);
else if(boxId==6)
fillColor = strokeColor = color(222,153,20);
else if(boxId==7)
fillColor = strokeColor = color(255,235,197);
else if(boxId==8)
fillColor = strokeColor = color(98,56,25);
else if(boxId==9)
fillColor = strokeColor = color(255,255,255);
}
void setThreshold( int newThreshold ){
threshold = newThreshold;
}
void setMaxPoints(int newMaxPoints) {
maxPoints = newMaxPoints;
}
void setColor(float red, float blue, float green){
fillColor = strokeColor = color(red, blue, green);
}
boolean check(PVector point) {
boolean result = false;
if (point.x > center.x - size/2 && point.x < center.x + size/2) {
if (point.y > center.y - size/2 && point.y < center.y + size/2) {
if (point.z > center.z - size/2 && point.z < center.z + size/2) {
result = true;
pointsIncluded++;
}
}
}
return result;
}
void draw() {
pushMatrix();
translate(center.x, center.y, center.z);
fill(red(fillColor), green(fillColor), blue(fillColor), 50 + 205 * percentIncluded());
stroke(red(strokeColor), green(strokeColor), blue(strokeColor), 255);
box(size);
popMatrix();
}
float percentIncluded() {
return map(pointsIncluded, 0, maxPoints, 0, 1);
}
boolean currentlyHit() {
return (pointsIncluded > threshold);
}
boolean isHit() {
return currentlyHit() && !wasJustHit;
}
boolean isLeft() {
return (pointsIncluded == 0) && (lastPointsIncluded > 0);
}
void clear() {
wasJustHit = currentlyHit();
lastPointsIncluded = pointsIncluded;
pointsIncluded = 0;
}
}
1