'Kinect'에 해당되는 글 4건

  1. 2013.01.15 [kinect] 가장 가까운 지점 구하기
반응형

import SimpleOpenNI.*;

SimpleOpenNI kinect;

int closestValue;

int closestX;

int closestY;

void setup()

{

size(640, 480);

kinect = new SimpleOpenNI(this);

kinect.enableDepth();

}

void draw()

{

closestValue = 8000;

kinect.update();

int[] depthValues = kinect.depthMap();

for(int y = 0; y < 480; y++){

// look at each pixel in the row

for(int x = 0; x < 640; x++){

int i = x + y * 640; 

int currentDepthValue = depthValues[i];

if(currentDepthValue > 0 && currentDepthValue < closestValue){ 

closestValue = currentDepthValue;

closestX = x;

closestY = y;

}

}

}

image(kinect.depthImage(),0,0);

fill(255,0,0);

ellipse(closestX, closestY, 25, 25);

}

Depth 이미지로부터 키넥트에 가장 가까운 지점에 원을 그리는 예제이다.  kinect.depthMap() 을 호출하여 depth의 Array 를 얻었고 for 문으로 가장 값이 낮은 값을 찾는다. 

다음은 실행 화면이다.

코 끝이 가장 키넥트 센서와 가까운것으로 나타난다. 

반응형
Posted by alias
,