【发布时间】:2015-03-26 16:17:05
【问题描述】:
我正在尝试创建一个直方图,显示 Kinect 扫描的距离与其出现的距离。我已经调整了直方图示例代码来创建深度直方图,但它目前在深度图像宽度上多次显示每个像素(从左到右)的深度。 我要做的是重新排序深度信息,使其范围从 x 轴上的最低值(不是 0)到最高值,并在 y 上显示它们的出现。我正在使用处理,所以我不确定这是否是正确的发布网站,但我已经在发布论坛上尝试过,但没有得到任何帮助。如果有人能告诉我哪里出错了,那就太棒了。我当前的代码如下,可以找到我当前输出的截图here
import SimpleOpenNI.*;
SimpleOpenNI kinect;
void setup() {
size(1200, 580);
kinect = new SimpleOpenNI(this);
kinect.enableDepth();
}
void draw () {
kinect.update();
PImage depthImage = kinect.depthImage();
image (depthImage, 11, 0);
int[] depthValues = kinect.depthMap();
int[] hist = new int[716800];
for (int x = 11; x < depthImage.width; x++) {
for (int y = 0; y < depthImage.height; y++) {
int i = x + y * 640;
hist[i] = depthValues[i];
}
}
int histMax = max(hist);
stroke(20);
for (int i = 0; i < depthImage.width; i += 2) {
int which = int(map(i, 0, depthImage.width, 0, histMax));
int y = int(map(hist[which], 0, histMax, depthImage.height, 0));
line(i, depthImage.height, i, y);
}
}
【问题讨论】:
标签: processing kinect histogram