and everything online says "where tolerance is the 'sensitivity' of the color tracking". Not very helpful.
How does the "tolerance" parameter actually work? I've been tracking white with
m.trackColor(255, 255, 255, 256*3-100)
Which I just got from some example code. But when I try to track red
m.trackColor(255, 0, 0, ANY_INTEGER)
...it doesn't work. Anyone know what the range of numbers is here? Does it change depending on how many color channels you're looking at? (The way the tolerance int is computed in the example code leads me to believe that it might be, since it's using an offset of a number*3.)
I wouldn't mind doing edits on a wiki documentation if someone can help clarify this.
I'm trying to get to the next step of doing things with arrays. Using the really excellent "Reach" examples, I'm trying to make the code work with an arbitrary number of arms, each following the ball (or pointer, or whatever)...
I've got a zillion arms going, that part's pretty easy. But they're all moving together. I'm having difficulty figuring out how to get each arm to do its own calculation for following the ball.
/**
* Reach 3.
* Based on code from Keith Peters (www.bit-101.com)
*
* The arm follows the position of the ball by
* calculating the angles with atan2().
*/
int numSegments = 6;
float armSpace = 25;
float[][] armArray;
float[] x = new float[numSegments];
float[] y = new float[numSegments];
float[] angle = new float[numSegments];
float segLength = 15;
float targetX, targetY;
float numArms = 1;
int rows = 2;
float ballX = 50;
float ballY = 50;
int ballXDirection = 1;
int ballYDirection = -1;
void setup() {
size(640, 200);
smooth();
strokeWeight(20.0);
stroke(0, 100);
noFill();
}
void draw() {
float numArms = width/armSpace;
background(226);
strokeWeight(20);
moveBall();
for (int k=0;k<rows;k++) {
for(int j=0;j<numArms;j++) {
x[x.length-1] = 0; // Set base x-coordinate
y[x.length-1] = height; // Set base y-coordinate
reachSegment(j, 0, ballX, ballY);
for(int i=1; i<numSegments; i++) {
reachSegment(j, i, targetX, targetY);
}
for(int i=x.length-1; i>=1; i--) {
positionSegment(i, i-1);
}
for(int i=0; i<x.length; i++) {
segment(x[i], y[i], angle[i], (i+1)*2);
}
translate(armSpace, 0);
}
translate(numArms*(-26), -25);
}
}
void positionSegment(int a, int b) {
x[b] = x[a] + cos(angle[a]) * segLength;
y[b] = y[a] + sin(angle[a]) * segLength;
}
void reachSegment(int num, int i, float xin, float yin) {
pushMatrix();
float dx = xin - x[i];
float dy = yin - y[i];
angle[i] = atan2(dy, dx);
targetX = xin - cos(angle[i]) * segLength;
targetY = yin - sin(angle[i]) * segLength;
popMatrix();
}
void segment(float x, float y, float a, float sw) {
After exporting this sketch (as an app to Mac OS X) I can run it fine on my computer, but not when copied to another computer. The app will launch, but just gives a black screen, doesn't access the iSight camera...
The two machines are both Snow Leopard MacBook Pros.
My code is [EDIT, now it's the most simple version that will create the error]:
import processing.video.*;
import hypermedia.video.*;
OpenCV opencv;
int w = 640;
int h = 480;
int COLOR_SPACE = OpenCV.RGB;
public void setup() {
size(640, 480, P2D);
frame.setBackground(new java.awt.Color(0, 0, 0));
frame.setTitle("can you hear me | 2010 | charlie williams");
This app, when exported, runs as expected on my machine. It doesn't run on my girlfriend's machine, though. I've tried the trick of moving the "java" folder from the Processing app into the sketch folder on her computer with no luck (although she and I are both running Snow Leopard, so Java should be a-ok without that).
Any tricks I need to know about? Any problems in this code that might keep it from exporting properly?
Thanks...
import processing.video.*;
import ddf.minim.analysis.*;
import ddf.minim.*;
import hypermedia.video.*;
Minim minim;
AudioInput in;
OpenCV opencv;
PImage bkgdImg;
PImage trailsImg;
PImage camImage;
int hCycle;
float audioAmp = 0.0;
float sampleAmp;
int w = 640;
int h = 480;
//int w = screen.width;
//int h = screen.height;
int COLOR_SPACE = OpenCV.RGB;
int vidFactor = 1;
color currColor;
public void setup() {
// size(screen.width, screen.height, P3D);
size(640, 480, P2D);
frame.setBackground(new java.awt.Color(0, 0, 0));
frame.setTitle("can you hear me | 2010 | charlie williams");
I figured out signing Applets. Hooray! Also compiling in 32-bit mode. Hip, hip!
--BUT--
[EDIT]
My code won't run in any of my browsers. (Chrome, Firefox, Safari) It prompts me to allow script access, and then prompts me for a file (that's what the example app does) but then doesn't display the image I pick to the screen. Just sits there...
My machine: MacBook Pro, 10.6.4. Everything runs fine locally.
The code is below...
Just to clarify, this sketch does not load any local data, like what you'd need to put in a /data/ folder.
Hi, I'm having a problem getting alpha to work properly. I'm using P3D and manually setting alpha bits using audio levels. I'm using println to verify that the color has changing alpha bits but none of that affects what's drawn to the screen. I've searched and searched and tried putting the calls in every order I can imagine. So far, no luck. Hopefully someone here can help.
The alphize(); function first:
void alphize() {
opencv.read();
opencv.flip(OpenCV.FLIP_HORIZONTAL);
camImage = opencv.image();
loadPixels();
for (int i = 0; i < IMG_HEIGHT * IMG_WIDTH; i++) {