As Movie class extends PImage, you can use PImage.pixels[] to access each pixel of current frame, check if it fits in some range of green shades and then set it's alpha to 0. You can read more on how to work with pixels, following this tutorial.
Well, I'm not so sure about these codes, cause I would do it differently. Maybe using video mask can improve performance, but I would go with the accessing pixels array, as I mentioned in my first answer. Maybe I'll try to download some footage with green screen and try to make an example, but a little later.
Answers
As Movie class extends PImage, you can use PImage.pixels[] to access each pixel of current frame, check if it fits in some range of green shades and then set it's alpha to 0. You can read more on how to work with pixels, following this tutorial.
Thanks! i tried that but did't work out..
Show your code, if it does not work, there should be a reason ;)
right now I'm working on this two code :
code 1 :
in this code : i got transparency but due to frame rate or something else i can see the black background instead of showing through them on webcam.
import processing.video.*;
Movie movie;
//PImage mask01;
Capture cam;
void setup() {
size(1280, 720);
movie = new Movie(this, "Drift.mov");
cam = new Capture(this, 1280, 720);
movie.loop();
// mask01 = createImage(width, height, 128);
frameRate(30);
cam.start();
}
void draw() {
cam.mask(movie);
image(movie, 0, 0);
image(cam, 0, 0);
println("FrameRate : "+frameRate);
}
void movieEvent(Movie movie) {
movie.read();
}
void captureEvent(Capture cam) {
cam.read();
}
-------------------------------
code 2 :
tried to play RGB & alpha video on webcam but i got problems with syncing up the RGB with the ALPHA movie.
my code :
int car;
float elcar_timespot;
float moviespeed = 0.05;
import processing.video.*;
Movie elcar, elcar_mask;
Capture cam;
void setup() {
size(1280, 720, JAVA2D);
frameRate(24);
cam = new Capture(this, 1280, 720);
cam.start();
elcar = new Movie(this, "car.mov");
elcar_mask = new Movie(this, "car_alpha.mov");
//imageMode(CENTER);
int car; } void captureEvent(Capture c) {
c.read(); } void draw() {
image(cam, 0, 0);
if (car == 1) {
} else {
} }
/* // speed 0.05
if (car == 1) { elcar_mask.read(); elcar.read();
} } */
void keyPressed() { if (key == 'a') { car = 1; } }
//void keyReleased() { // if (key == 'a') { // car = 0; // } //}
Well, I'm not so sure about these codes, cause I would do it differently. Maybe using video mask can improve performance, but I would go with the accessing pixels array, as I mentioned in my first answer. Maybe I'll try to download some footage with green screen and try to make an example, but a little later.
Please format your code for the forum.
https://forum.processing.org/two/discussion/8045/how-to-format-code-and-text#latest
maybe this can inspire you. It's working in a still image though, and removing red, but the idea to handle the pixels might be interesting.
@Ater ok Thanks! i will try using PImage.pixels[] and if i got transparency will let you know . :)
@ _vk Thanks ! for info. and ok will try with your code :)
and my formated code
code 1 :
in this code : i got transparency but due to frame rate or something else i can see the black background instead of showing through them on webcam.
-------------------------- code 2 :
tried to play RGB & alpha video on webcam but i got problems with syncing up the RGB with the ALPHA movie.
Dunno whether it's gonna be of any help, but here's something I did some months ago w/ Movie + PImage + mask() + arrayCopy() +
pixels[]
: >-)https://forum.Processing.org/two/discussion/12609/random-videos-displaying-in-different-masks
sorry for too late reply ...
as you move mouse it remove green pixel's but don't know why its not removing all green pixel's..