顯示具有 Week11 標籤的文章。 顯示所有文章
顯示具有 Week11 標籤的文章。 顯示所有文章

2015年6月15日 星期一

期末作業-進度

Let's share color!

構思
在Youtube找到影片:
2011大葉大學14屆視傳系形象長片-視界交互【點點人3主打】
https://www.youtube.com/watch?v=_8E6w0irTQE






看到這個影片產生了將它做成互動軟體的想法,偵測到人利用圓點印出,能多人一起使用,每個人都能有自己的顏色,並且能分享自己的顏色給對方





設計過程:

開始步驟:
  1. 如何印出點點人?
  2. 人如何有顏色?
  3. 如何互相變顏色?




步驟1.印出點點人






步驟2.人如何有顏色
先用矩陣宣告顏色

color[]       userClr = new color[]{ color(255,0,0),
                                     color(0,255,0),
                                     color(0,0,255),
                                     color(255,255,0),
                                     color(255,0,255),
                                     color(0,255,255)
                                   };


將人物的點點填入顏色
  blob_array[index] = 5; //矩陣裡六個顏色
        //fill(GRAY);  這邊是原本還沒加入彩色時先令他為灰階
         fill(userClr[ (userMap[index] - 1) % userClr.length ], 50);  //填入顏色矩陣的色彩

預設第一人為紅色

偵測到第二個人
預設第二人為綠色


第三人為藍色,第四人為黃色,第五人為紫紅色,第六人為淡藍色。









步驟3.如何互相改變顏色?
Let's share color!



當紅色的人碰到綠色的人時,碰到的部分會變成紅色,慢慢地整個人會變成紅色。
當紅色的人不再接觸後,原本的綠色人會變成紅色,而原本紅色的人會變成下一個顏色。











這就是分享顏色!!!!!!!!


2015年5月4日 星期一

Week11

-------------------------------↓↓Kinect範例程式↓↓-------------------------------


* prog: Max Rheiner / Interaction Design / Zhdk / http://iad.zhdk.ch/
* date: 12/12/2012 (m/d/y)
* ----------------------------------------------------------------------------
*/

import SimpleOpenNI.*;


SimpleOpenNI context;

void setup()
{
size(640*2, 480);
context = new SimpleOpenNI(this);
if (context.isInit() == false)
{
println("Can't init SimpleOpenNI, maybe the camera is not connected!");
exit();
return;
}

// mirror is by default enabled
context.setMirror(true);

// enable depthMap generation
context.enableDepth();

// enable ir generation
context.enableRGB();
}

void draw()
{
// update the cam
context.update();

background(200, 0, 0);

// draw depthImageMap
image(context.depthImage(), 0, 0);

// draw irImageMap
image(context.rgbImage(), context.depthWidth() + 10, 0);
}



-------------------------------↓↓DepthMap3D↓↓-------------------------------




/* --------------------------------------------------------------------------
* SimpleOpenNI DepthMap3d Test
* --------------------------------------------------------------------------
* Processing Wrapper for the OpenNI/Kinect 2 library
* http://code.google.com/p/simple-openni
* --------------------------------------------------------------------------
* prog: Max Rheiner / Interaction Design / Zhdk / http://iad.zhdk.ch/
* date: 12/12/2012 (m/d/y)
* ----------------------------------------------------------------------------
*/

import SimpleOpenNI.*;

SimpleOpenNI context;
float zoomF =0.3f;
float rotX = radians(180); // by default rotate the hole scene 180deg around the x-axis,
// the data from openni comes upside down
float rotY = radians(0);

void setup()
{
size(1024,768,P3D);

context = new SimpleOpenNI(this);
if(context.isInit() == false)
{
println("Can't init SimpleOpenNI, maybe the camera is not connected!");
exit();
return;
}

// disable mirror
context.setMirror(false);

// enable depthMap generation
context.enableDepth();

stroke(255,255,255);
smooth();
perspective(radians(45),
float(width)/float(height),
10,150000);
}

void draw()
{
// update the cam
context.update();

background(0,0,0);

translate(width/2, height/2, 0);
rotateX(rotX);
rotateY(rotY);
scale(zoomF);

int[] depthMap = context.depthMap();
int steps = 3; // to speed up the drawing, draw every third point
int index;
PVector realWorldPoint;

translate(0,0,-1000); // set the rotation center of the scene 1000 infront of the camera

stroke(255);

PVector[] realWorldMap = context.depthMapRealWorld();

// draw pointcloud
beginShape(POINTS);
for(int y=0;y < context.depthHeight();y+=steps)
{
for(int x=0;x < context.depthWidth();x+=steps)
{
index = x + y * context.depthWidth();
if(depthMap[index] > 0)
{
// draw the projected point
// realWorldPoint = context.depthMapRealWorld()[index];
realWorldPoint = realWorldMap[index];
vertex(realWorldPoint.x,realWorldPoint.y,realWorldPoint.z); // make realworld z negative, in the 3d drawing coordsystem +z points in the direction of the eye
}
//println("x: " + x + " y: " + y);
}
}
endShape();

// draw the kinect cam
context.drawCamFrustum();
}


void keyPressed()
{
switch(key)
{
case ' ':
context.setMirror(!context.mirror());
break;
}

switch(keyCode)
{
case LEFT:
rotY += 0.1f;
break;
case RIGHT:
// zoom out
rotY -= 0.1f;
break;
case UP:
if(keyEvent.isShiftDown())
zoomF += 0.02f;
else
rotX += 0.1f;
break;
case DOWN:
if(keyEvent.isShiftDown())
{
zoomF -= 0.02f;
if(zoomF < 0.01)
zoomF = 0.01;
}
else
rotX -= 0.1f;
break;
}
}

01160873_林瑋真



                                                                     DepthImage

* prog:  Max Rheiner / Interaction Design / Zhdk / http://iad.zhdk.ch/
 * date:  12/12/2012 (m/d/y)
 * ----------------------------------------------------------------------------
 */

import SimpleOpenNI.*;


SimpleOpenNI  context;

void setup()
{
  size(640*2, 480);
  context = new SimpleOpenNI(this);
  if (context.isInit() == false)
  {
    println("Can't init SimpleOpenNI, maybe the camera is not connected!"); 
    exit();
    return;
  }

  // mirror is by default enabled
  context.setMirror(true);

  // enable depthMap generation 
  context.enableDepth();

  // enable ir generation
  context.enableRGB();
}

void draw()
{
  // update the cam
  context.update();

  background(200, 0, 0);

  // draw depthImageMap
  image(context.depthImage(), 0, 0);

  // draw irImageMap
  image(context.rgbImage(), context.depthWidth() + 10, 0);
}




DepthMap3D

/* --------------------------------------------------------------------------
 * SimpleOpenNI DepthMap3d Test
 * --------------------------------------------------------------------------
 * Processing Wrapper for the OpenNI/Kinect 2 library
 * http://code.google.com/p/simple-openni
 * --------------------------------------------------------------------------
 * prog:  Max Rheiner / Interaction Design / Zhdk / http://iad.zhdk.ch/
 * date:  12/12/2012 (m/d/y)
 * ----------------------------------------------------------------------------
 */

import SimpleOpenNI.*;

SimpleOpenNI context;
float        zoomF =0.3f;
float        rotX = radians(180);  // by default rotate the hole scene 180deg around the x-axis, 
                                   // the data from openni comes upside down
float        rotY = radians(0);

void setup()
{
  size(1024,768,P3D);

  context = new SimpleOpenNI(this);
  if(context.isInit() == false)
  {
     println("Can't init SimpleOpenNI, maybe the camera is not connected!"); 
     exit();
     return;  
  }
  
  // disable mirror
  context.setMirror(false);

  // enable depthMap generation 
  context.enableDepth();

  stroke(255,255,255);
  smooth();
  perspective(radians(45),
              float(width)/float(height),
              10,150000);
}

void draw()
{
  // update the cam
  context.update();

  background(0,0,0);

  translate(width/2, height/2, 0);
  rotateX(rotX);
  rotateY(rotY);
  scale(zoomF);

  int[]   depthMap = context.depthMap();
  int     steps   = 3;  // to speed up the drawing, draw every third point
  int     index;
  PVector realWorldPoint;

  translate(0,0,-1000);  // set the rotation center of the scene 1000 infront of the camera

  stroke(255);

  PVector[] realWorldMap = context.depthMapRealWorld();
  
  // draw pointcloud
  beginShape(POINTS);
  for(int y=0;y < context.depthHeight();y+=steps)
  {
    for(int x=0;x < context.depthWidth();x+=steps)
    {
      index = x + y * context.depthWidth();
      if(depthMap[index] > 0)
      { 
        // draw the projected point
//        realWorldPoint = context.depthMapRealWorld()[index];
        realWorldPoint = realWorldMap[index];
        vertex(realWorldPoint.x,realWorldPoint.y,realWorldPoint.z);  // make realworld z negative, in the 3d drawing coordsystem +z points in the direction of the eye
      }
      //println("x: " + x + " y: " + y);
    }
  } 
  endShape();
  
  // draw the kinect cam
  context.drawCamFrustum();
}


void keyPressed()
{
  switch(key)
  {
  case ' ':
    context.setMirror(!context.mirror());
    break;
  }

  switch(keyCode)
  {
  case LEFT:
    rotY += 0.1f;
    break;
  case RIGHT:
    // zoom out
    rotY -= 0.1f;
    break;
  case UP:
    if(keyEvent.isShiftDown())
      zoomF += 0.02f;
    else
      rotX += 0.1f;
    break;
  case DOWN:
    if(keyEvent.isShiftDown())
    {
      zoomF -= 0.02f;
      if(zoomF < 0.01)
        zoomF = 0.01;
    }
    else
      rotX -= 0.1f;
    break;
  }
}




Week11

課堂範例
DepthMap3D

User3D

User