// 카메라를 통해 움직이는(변화하는) 물체의 최상단 점을 찾아....
import JMyron.*;
JMyron m;
void setup () {
size(160,120);
m = new JMyron();
m.start(160,120);
}
float totalX,totalY,totalCount;
float oldX=0,oldY=0;
int cameraPixelsOld[] = new int[160*120];
void draw() {
m.update();
//totalX=0;
//totalY=0;
totalCount=0;
int cameraPixels[] = m.image();
background(255);
int index = 0;
boolean isChecked = false;
for (int y=0; y<120; y++) {
for (int x=0; x<160; x++) {
index = x + y*160;
if (abs(brightness(cameraPixelsOld[index])-brightness(cameraPixels[index]))>90) {
if (!isChecked) {
totalX = (float)x;
totalY = (float)y;
isChecked = true;
}
stroke(cameraPixels[index]);
point(x,y);
}
}
}
cameraPixelsOld = cameraPixels;
line(oldX,oldY,totalX,totalY);
fill(255,0,0);
rectMode(CENTER);
rect(totalX,totalY,10,10);
oldX = totalX;
oldY = totalY;
}





