Kinect: Difference between revisions

Jump to navigation Jump to search
No edit summary
No edit summary
Line 28: Line 28:
|}
|}
== Presentation software ==
== Presentation software ==
<nocms>
begin;
array{
  ellipse_graphic {
      ellipse_width = 1;
      ellipse_height = 1;
      color = 255, 0, 0;
  };
  ellipse_graphic {
      ellipse_width = 1;
      ellipse_height = 1;
      color = 0, 255, 0;
  };
}arrayJoints;
picture {
text { font = "Arial"; font_size = 20; caption = "move a bit:)"; } cap;
x = 0; y = -400;
} pic;
begin_pcl;
array<vector> data[0]; # in centimeters
array<int> body_ids[0];
int counter = 0, dataBody;
string toScreen;
sub change_caption( string caption ) begin
cap.set_caption( caption, true );
pic.present()
end;
sub showJoint( int joint , int partNr) begin
pic.set_part_x(partNr+1,data[joint].x() * 10);
pic.set_part_y(partNr+1,data[joint].y() * 10);
if partNr <= 3 then
arrayJoints[partNr].set_dimensions(data[joint].z(),data[joint].z());
arrayJoints[partNr].redraw();
end;
end;
kinect k = new kinect();
depth_data dd = k.depth();
dd.RES_512x424;
body_tracker tracker = k.body();
tracker.set_seated( true );
tracker.start();
pic.present();
body_data bd;
loop until !is_null( bd ) begin
bd = tracker.get_new_body();
end;
#add the joints to picture
loop
int count = 1;
until count > 6 begin
pic.add_part(arrayJoints[count],0,0);
count = count + 1;
end;
dd.start();
loop until false begin
  if (dd.new_data()) then
counter = counter + 1;
bd.get_positions( data, body_ids);
if data.count() > 0 then
showJoint(bd.HAND_RIGHT,1);
showJoint(bd.HAND_LEFT,2);
showJoint(bd.HEAD,3);
showJoint(bd.WRIST_RIGHT,4);
showJoint(bd.HAND_TIP_RIGHT ,5);
showJoint(bd.THUMB_RIGHT,6);
toScreen = "dataCount: " + string(counter) + "\n";
toScreen.append("data X: " + string(data[bd.HAND_RIGHT].x()) + "\n");
toScreen.append("data Y: " + string(data[bd.HAND_RIGHT].y()) + "\n");
toScreen.append("dataZ: " + string(data[bd.HAND_RIGHT].z()) + "\n");
change_caption( toScreen );
end;
  end;
end;
</nocms>