【发布时间】:2019-04-18 17:30:51
【问题描述】:
我现在正在运行编码培训教程。但是按照他的指示,我不断收到错误消息。有人可以告诉我我的代码有什么问题吗?
import org.openkinect.processing.*;
Kinect kinect;
void setup() {
PImage img;
size(512, 484);
kinect = new Kinect(this);
kinect.initDepth();
img = createImage(kinect.width, kinect.height, RGB);
}
void draw() {
background(0);
img.loadPixels();
int[] depth = kinect.getRawDepth();
for (int x = 0; x < kinect.width; x++) {
for (int y = 0; y < kinect.height; y++) {
int offsett = x + y * kinect.width;
int d = depth[offsett];
img.pixels[offset] = color(255,0,150);
}
}
img.updatePixels();
image(img, 0, 0);
}
感谢您的帮助!
【问题讨论】:
-
函数中定义的东西保留在那些函数中。如果您需要一个全局变量
img,请在setup之外全局定义它,就像您已经使用kinect一样。
标签: processing kinect