Hello,
I'm not very used to processing yet... I've just started making sketches a half year ago. It works very well, but nevertheless I have a problem:
I just understand how I can attach videos in Processing and manage how I can start, stop it and jump to a certain frame. I understand how I can grap the webcam but I don't know how I can measure activity within the captured picture.
I just found a side www.creativecoding.org with a code to understand how activity measuring works, but I think this is not the right solution (and I must confess that I don't understand the code completely).
The only thing I want is, if the cam measures a certain amount of activity that the video played in a second sketch will jump to a certain frame and if the activity's amount under a certain level that it will jump back.
I also have a second problem that I don't know how to attach two sketchs with each other.
can anybody help me... this might be a noob question but I really don't get further.
this is my sketch:
it works well but I don't know exactly how I can determine the value exactly... also it would be necessary that i can view the rect in a second window... the rest I would manage by myself I think...
many thanks!
Jerome
I'm not very used to processing yet... I've just started making sketches a half year ago. It works very well, but nevertheless I have a problem:
I just understand how I can attach videos in Processing and manage how I can start, stop it and jump to a certain frame. I understand how I can grap the webcam but I don't know how I can measure activity within the captured picture.
I just found a side www.creativecoding.org with a code to understand how activity measuring works, but I think this is not the right solution (and I must confess that I don't understand the code completely).
The only thing I want is, if the cam measures a certain amount of activity that the video played in a second sketch will jump to a certain frame and if the activity's amount under a certain level that it will jump back.
I also have a second problem that I don't know how to attach two sketchs with each other.
can anybody help me... this might be a noob question but I really don't get further.
this is my sketch:
- import processing.video.*;
final int VID_WIDTH = 640;
final int VID_HEIGHT = 480;
float[] buffer1 = new float[VID_WIDTH * VID_HEIGHT];
float[] buffer2 = new float[buffer1.length];
float[] buffer3 = new float[buffer1.length];
float threshold = 400;
Capture cam;
void setup() {
size (VID_WIDTH, VID_HEIGHT);
cam = new Capture (this, VID_WIDTH, VID_HEIGHT);
frameRate(15);
cam.start();
}
void draw() {
if (cam.available ()) {
cam.read();
background(0);
image(cam, 0, 0);
loadPixels();
for (int i=0; i < cam.pixels.length; i++) {
color c = cam.pixels[i];
float sumC = red(c) + green(c) + blue(c);
float deltaPixel = (buffer1[i] + buffer2[i] + buffer3[i]) / 3 - sumC;
if (deltaPixel > threshold) {
noStroke();
fill(0, 255, 255);
rectMode(CENTER);
rect(320, 240, deltaPixel / 5 , deltaPixel / 5);
}
buffer3[i] = buffer2[i];
buffer2[i] = buffer1[i];
buffer1[i] = sumC;
}
loadPixels();
}
}
it works well but I don't know exactly how I can determine the value exactly... also it would be necessary that i can view the rect in a second window... the rest I would manage by myself I think...
many thanks!
Jerome