How are you going to see a black square on a "white" screen?
I would suggest some calibration before delving into the mysteries of different image scanning softwares. You need to know that for starters you can actually see the objects with your current hardware.
The following code tests your theory but I'm lacking a web cam right now to test it myself, let alone a projector. Use the calibration mode to align the projection with the image the webcam sees (there will be distortion owing to the distance from the cam to the projection).
You should get a print out of varying value if firing something into the projected black square is fruitful. Hope this helps.
Code:
import processing.video.*;
Capture myCapture;
ScanMe myBox;
boolean calibrate;
void setup(){
size(640, 480);
myCapture = new Capture(this, width, height, 24);
myCapture.loadPixels();
myBox = new ScanMe(300, 300, 100, 100);
fill(0);
}
void draw(){
if(!calibrate){
background(255);
rect(myBox.x, myBox.y, myBox.w, myBox.h);
println(myBox.scan());
} else {
image(myCapture, 0, 0);
}
}
void keyPressed(){
calibrate = !calibrate;
}
void captureEvent(Capture myCapture){
myCapture.read();
}
class ScanMe{
int x, y, w, h;
int speed = 2;
ScanMe(int x, int y, int w, int h){
this.x = x;
this.y = y;
this.w = w;
this.h = h;
}
int scan(){
int val = 0;
myCapture.updatePixels();
for(int i = 0; i < w * h; i+=speed){
val += gray(pixels[i]);
}
return val;
}
}
static int gray(color p){
return max((p >> 16) & 0xFF, (p >> 8) & 0xFF, p & 0xFF);
}