2012-03-06 6 views
0

ポイントクラウドを取得する処理を使用しようとしています。しかし、それは動作しないことが判明しましたKinectを使ったsimpleopenniポイントクラウドプログラム

import SimpleOpenNI.*; 

import processing.opengl.*; 

SimpleOpenNI kinect; 

void setup() 
{ 

    size(1024, 768, OPENGL); 

    kinect = new SimpleOpenNI(this); 

    kinect.enableDepth(); 

} 

void draw() 
{ 

    background(0); 

    kinect.update(); 

    translate(width/2, height/2, -1000); 

    rotateX(radians(180)); 

stroke(255); 

    PVector[] depthPoints = kinect.depthMapRealWorld(); 

    //the program get stucked in the for loop it loops 307200 times and I don't have any points output 

    for(int i = 0; i < depthPoints.length ; i++) 
    { 

    PVector currentPoint = depthPoints[i]; 

    point(currentPoint.x, currentPoint.y, currentPoint.z); 
    } 

} 
+0

エラーはありません。私は500ピクセルをスキップするとポイントを得ることができます(あまりにも多くスキップすることになります)。最初のポイントも働いています。 – xinghua

答えて

1

あなたのコードは、うまく、ちょうどテストされています。 奥行き画像(640x480 = 307200)のデータを3D位置に変換するため、ループ回数が307200回になります。

本当に間違いはありませんか? また、Processing内のすべてのポイントを描画するのは少し遅いですが、少しスキップすることもできます。 および試験として、第1の点を印刷し、参照しようとした場合、すべての値の変化(それが必要) または深さイメージは、任意のデータがある場合(黒でない/ゼロで満たされた):

import SimpleOpenNI.*; 

import processing.opengl.*; 

SimpleOpenNI kinect; 

void setup() 
{ 

    size(1024, 768, OPENGL); 

    kinect = new SimpleOpenNI(this); 

    kinect.enableDepth(); 

} 

void draw() 
{ 

    background(0); 

    kinect.update(); 
    image(kinect.depthImage(),0,0,160,120);//check depth image 

    translate(width/2, height/2, -1000); 

    rotateX(radians(180)); 

    stroke(255); 

    PVector[] depthPoints = kinect.depthMapRealWorld(); 

    //the program get stucked in the for loop it loops 307200 times and I don't have any points output 

    for(int i = 0; i < depthPoints.length ; i+=4)//draw point for every 4th pixel 
    { 

    PVector currentPoint = depthPoints[i]; 
    if(i == 0) println(currentPoint); 
    point(currentPoint.x, currentPoint.y, currentPoint.z); 
    } 

} 
+0

エラーはありません。私は500ピクセルをスキップするとポイントを得ることができます(これはあまりにも多くスキップすることになります)。最初のポイントも働いています。 – xinghua

+0

@xinghuaそれは奇妙です。奥行き画像は、グレースケール、クリップされていない/黒い/その他のように見えますか?また、SimpleOpenNIに付属のDepthMap3dサンプルを正常に実行できますか? –

+0

私はそれが表示するには遅すぎると言った。私が得るものは悪い性質を持っています。あなたが多くの点を飛ばすならば、あなたはラインでポイントの束を見ることができます。しかし、サンプルは完璧であることが分かります。 – xinghua

関連する問題