Sending Kinect Depth Data to Arduino through Serial Questions!
in
Integration and Hardware
•
1 year ago
The problem I am having is trying to figure out the byte/value/pixel range size that is being sent to the arduino. Using the following as imports : SimpleOpenNI and processing.serial. Code is here:
//if user is successfully calibrated
if ( kinect.isTrackingSkeleton(userId)) {
drawSkeleton(userId); //draw the skeleton on the depth image
PVector torso = new PVector(); //make a vector to store torso
kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_TORSO, torso); //put the position of torso into vector
port.write(int(torso.z)); //z-coordinate corresponds to how far it is from kinect, convert to int and send data through serial port
}
I found the user's torso.z from depth image and sent this to arduino.
The corresponding arduino code is here :
void loop(){
if(Serial.available() > 0)
{
serialData = Serial.read();
Serial.println(serialData);
}
}
From here I'd like to set up a threshold for my motors to maintain. Having them both spin forward/backward to maintain 3 feet from the kinect except I don't know the depth integer range that I can manipulate. Kinect depth range can be from 0 to 80k pixels.
//if user is successfully calibrated
if ( kinect.isTrackingSkeleton(userId)) {
drawSkeleton(userId); //draw the skeleton on the depth image
PVector torso = new PVector(); //make a vector to store torso
kinect.getJointPositionSkeleton(userId, SimpleOpenNI.SKEL_TORSO, torso); //put the position of torso into vector
port.write(int(torso.z)); //z-coordinate corresponds to how far it is from kinect, convert to int and send data through serial port
}
I found the user's torso.z from depth image and sent this to arduino.
The corresponding arduino code is here :
void loop(){
if(Serial.available() > 0)
{
serialData = Serial.read();
Serial.println(serialData);
}
}
From here I'd like to set up a threshold for my motors to maintain. Having them both spin forward/backward to maintain 3 feet from the kinect except I don't know the depth integer range that I can manipulate. Kinect depth range can be from 0 to 80k pixels.
1