We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Nerf Shooting Range Idea
Page Index Toggle Pages: 1
Nerf Shooting Range Idea (Read 721 times)
Nerf Shooting Range Idea
Oct 30th, 2006, 4:42pm
 
I wasn't sure where to put this, so I apologize.

I would like to run this idea with everyone, so feel free to add any suggestions.
I work in a large studio with a lot of space, including a large white wall. We also have a projector, webcam and a few nerf guns. I figure to put all that together to create an interactive nerf shooting range.

I was thinking of using processing/projector to display the targets (random images) and use the webcam to check for hits.

Right now I'm thinking of using a white blackground with black shape as targets. The nerf darts are yellow.

I guess I could do a blobdetection and check if the "dart blob" is inside the  "target blob". Does anyone have any suggestions on how to check if the dart hits the black shape?
Re: Nerf Shooting Range Idea
Reply #1 - Oct 30th, 2006, 10:23pm
 
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);
}
Re: Nerf Shooting Range Idea
Reply #2 - Oct 30th, 2006, 10:29pm
 
i haven't tried anything yet, it was just an idea i came up in the morning.
thanks for the reply and suggestion. I will try it out.
Page Index Toggle Pages: 1