• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Greenfoot & Kinect (Parte 3)
 

Greenfoot & Kinect (Parte 3)

on

  • 962 views

Programando el Kinect con Greenfoot, parte 3.

Programando el Kinect con Greenfoot, parte 3.
Clase de Proyecto de Diseño de Videojuegos @ ITESM SLP

Statistics

Views

Total Views
962
Views on SlideShare
961
Embed Views
1

Actions

Likes
1
Downloads
10
Comments
0

1 Embed 1

http://www.docshut.com 1

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Greenfoot & Kinect (Parte 3) Greenfoot & Kinect (Parte 3) Presentation Transcript

    • Programando elKinect con Greenfoot (3) Eduardo H. Calvillo Gámez
    • Calibrando Usuarios Clase UserData  Métodos  isTracking();  Booleano, nos indica si esta haciendo “tracking” pues ya termino de calibrar.  isCalibrating();  Booleano, nos indica si esta calibrando. Clase KinectWorld  getAllUsers();  Arreglo de UserData, todos los usuarios frente al Kinect.
    • Ejemplo:Instrucciones.java Método act() & addedToWorld(…)
    • //Método act()KinectWorld world = (KinectWorld)getWorld(); boolean trackingAny = false; boolean calibratingAny = false; UserData[] us = world.getAllUsers(); for (UserData u : us) { trackingAny = trackingAny || u.isTracking(); calibratingAny = calibratingAny || u.isCalibrating(); } if (us.length > 0 && !trackingAny && ! calibratingAny) { setImage(begin); } else if (us.length > 0 && !trackingAny && calibratingAny) { setImage(calibrating); } else { setImage(blank); } }
    • protected void addedToWorld(World world) { begin = new GreenfootImage("begin.png"); begin.scale(world.getWidth(), world.getHeight()); calibrating = new GreenfootImage("calibrating.png"); calibrating.scale(world.getWidth(), world.getHeight()); blank = new GreenfootImage(1, 1); setImage(blank); }
    • Usuarios Clase UserData  drawStickFigure(…)  drawStickFigure(getBackground(), 60);  getJoint Clase Joint  Constantes para cada parte del cuerpo getJoint(Joint.LEFT_HAND) nos regresa la parte que indicamos (objeto de tipo Joint)
    • Ejemplo Para checar si alguien levanto la mano izquierda  u.getJoint(Joint.LEFT_HAND).getY() < u.getJoint(Joint.HEAD).getY()
    • EjemploDibujando con la mano derecha
    • import greenfoot.*;public class Brocha extends Actor{ public Brocha(int width, int height) { setImage(new GreenfootImage(width, height)); getImage().setColor(java.awt.Color.GREEN); } public void act() { PaintWorld world = (PaintWorld)getWorld(); UserData[] users = world.getTrackedUsers(); for (UserData user : users) { Joint rightHand = user.getJoint(Joint.RIGHT_HAND); getImage().fillOval(rightHand.getX(), rightHand.getY(), 20, 20); if (user.getJoint(Joint.LEFT_HAND).getY() < user.getJoint(Joint.HEAD).getY()) { getImage().clear(); } } }}
    • Ejemplo PintarMundo
    • public class PintarMundo extends KinectWorld{ private static final int THUMBNAIL_WIDTH = 80; private static final int THUMBNAIL_HEIGHT = 60; … public PintarMundo() { super(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, 1.0, false); final int width = getWidth(); final int height = getHeight(); addObject(new Brocha(width, height), width/2, height/2); addObject(new Instructiones(), width/2, height/2); addObject(new Foto(), width - THUMBNAIL_WIDTH/2, height -THUMBNAIL_HEIGHT/2); Label instr = new Label(”Usa la mano derecha para pintar, la izquierdapara borrar", 20); addObject(instr, instr.getImage().getWidth() /2, getBackground().getHeight() - (instr.getImage().getHeight() / 2)); }
    • public void act() { super.act(); if (!isConnected()) return; UserData[] us = getTrackedUsers(); getBackground().setColor(java.awt.Color.WHITE); getBackground().fill(); for (UserData u: us) { //Draws their stick figure: u.drawStickFigure(getBackground(), 60);}