Hi there I'm working with a kinect to control the playhead and selection of a few videos depending on user position. The code for this I have working fine. Its the implementation of the videos. I've tried the inherent and GSVideo libraries. I'm naming a PImage to hold pixels from the video so that I can use the Alpha channel to blend between video. However, I'm having some issues with the PImage drawing no Alpha even though this is controlled by User Z value (or in the code below mouseY). I've simplified the sketch down and using mouse co-ordinates to represent kinect data.
If you move the mouse around a couple of circuits it works great. It is when you linger on one video zone that the alpha transparency remains 0 or just shows black pixels.
With the inherent processing video libray it comes back with a random QT error and the playhead jump stops working (QTNullPointerException: The QT native object represented by this QTJava object is not valid:quicktime.qd.Pict).
The GSVideo library implemented just stops drawing updated pixels but println is working so finding it hard to debug.
Using a 2.4Ghz Intel Core 2 with 4gb of ram. I know that this isn't the most powerful machine but surely it should be able to cope with such a simple task? All videos have been compressed to 24 fps and low bitrate to keep memory down and the CPU is still being stretched to over 80%.
Any help would be greatly appreciated.
Inherent Video Library Code:
import processing.video.*;
Movie movieBottom;
Movie movieMiddle;
Movie movieTop;
PImage TopAlpha ;
PImage MiddleAlpha;
int transparencyTop;
int transparencyMiddle;
float playheadBottom;
float playheadTop;
float playheadMiddle;
void setup() {
size(1024, 576, P3D);
frameRate(24);
TopAlpha = createImage(width, height, ARGB);
MiddleAlpha = createImage(width, height, ARGB);
movieTop = new Movie(this, "top.mov");
movieMiddle = new Movie(this, "middle.mov");
movieBottom = new Movie(this, "bottom.mov");
movieBottom.play();
movieTop.play();
movieMiddle.play();
}
void draw() {
println (mouseY);
background(0);
if(mouseY<101){
image (movieTop, 0, 0);
playheadTop = map(mouseX, 0, width, 0, movieTop.duration());
movieTop.jump(playheadTop);
println ("playingTop");
}
else if ((mouseY<170)&&(mouseY>100)) {//next zone <(height/3) && <(height/3)*2
println("blending");
transparencyTop = (int) map(mouseY, 170, 100, 0.0, 255.0);
movieTop.loadPixels();
TopAlpha.loadPixels();
int x=0;
int y=0;
for (int i = 0; i < TopAlpha.pixels.length; i++) {
color myColor = movieTop.get(x, y);
TopAlpha.pixels[i]= color(myColor, transparencyTop);
x++;
if (x>=width) {
x=0;
y++;
}
}
updatePixels();
image (movieMiddle, 0, 0);
image(TopAlpha, 0, 0);
playheadMiddle = map(mouseX, 0, width, 0, movieMiddle.duration());
playheadTop = map(mouseX, 0, width, 0, movieTop.duration());
movieMiddle.jump(playheadMiddle);
movieTop.jump(playheadTop);
}
else if ((mouseY>150)&& (mouseY<251)){
image (movieMiddle, 0, 0);
playheadMiddle = map(mouseX, 0, width, 0, movieMiddle.duration());
movieMiddle.jump(playheadMiddle);
println("playingMiddle");
}
else if ((mouseY > 250 ) && (mouseY<385)) {
println("blending2");
transparencyMiddle = (int) map(mouseY, 385, 250, 0.0, 255.0);
movieMiddle.loadPixels();
MiddleAlpha.loadPixels();
int x=0;
int y=0;
for (int i = 0; i < MiddleAlpha.pixels.length; i++) {
color myColor = movieMiddle.get(x, y);
MiddleAlpha.pixels[i]= color(myColor, transparencyMiddle);
x++;
if (x>=width) {
x=0;
y++;
}
}
updatePixels();
image (movieBottom, 0, 0);
image(MiddleAlpha, 0, 0);
playheadBottom = map(mouseX, 0, width, 0, movieBottom.duration());
playheadMiddle = map(mouseX, 0, width, 0, movieMiddle.duration());
movieBottom.jump(playheadBottom);
movieMiddle.jump(playheadMiddle);
}
else if (mouseY >384) {
println ("playing bottom");
image (movieBottom, 0, 0);
playheadBottom = map(mouseX, 0, width, 0, movieBottom.duration());
movieBottom.jump(playheadBottom);
}
}
GSVideo Code:
//loosing memory of previos videos.. even though printing the print line not showin image
import processing.video.*;
import codeanticode.gsvideo.*;
GSMovie movieBottom;
GSMovie movieMiddle;
GSMovie movieTop;
PImage TopAlpha ;
PImage MiddleAlpha;
int transparencyTop;
int transparencyMiddle;
float playheadBottom;
float playheadTop;
float playheadMiddle;
void setup() {
size(1024, 576, P3D);
frameRate(24);
TopAlpha = createImage(width, height, ARGB);
MiddleAlpha = createImage(width, height, ARGB);
movieTop = new GSMovie(this, "top.mov");
movieMiddle = new GSMovie(this, "middle.mov");
movieBottom = new GSMovie(this, "bottom.mov");
movieBottom.play();
movieTop.play();
movieMiddle.play();
}
void movieEvent(GSMovie m) {
m.read();
}
void draw() {
println (mouseY);
background(255);
if(mouseY<101){
playheadTop = map(mouseX, 0, width, 0, movieTop.duration());
movieTop.jump(playheadTop);
println ("playingTop");
image (movieTop, 0, 0);
println("image = Top");
}
else if ((mouseY<170)&&(mouseY>100)) {//next zone <(height/3) && <(height/3)*2
transparencyTop = (int) map(mouseY, 170, 100, 0.0, 255.0);
movieTop.loadPixels();
TopAlpha.loadPixels();
int x=0;
int y=0;
for (int i = 0; i < TopAlpha.pixels.length; i++) {
color myColor = movieTop.pixels[i];
TopAlpha.pixels[i]= color(myColor, transparencyTop);
x++;
if (x>=width) {
x=0;
y++;
}
}
movieTop.updatePixels();
TopAlpha.updatePixels();
image (movieMiddle, 0, 0);
image(TopAlpha, 0, 0);
playheadMiddle = map(mouseX, 0, width, 0, movieMiddle.duration());
playheadTop = map(mouseX, 0, width, 0, movieTop.duration());
movieMiddle.jump(playheadMiddle);
movieTop.jump(playheadTop);
println("blending");
}
else if ((mouseY>150)&& (mouseY<251)){
image (movieMiddle, 0, 0);
playheadMiddle = map(mouseX, 0, width, 0, movieMiddle.duration());
movieMiddle.jump(playheadMiddle);
println("playingMiddle");
}
else if ((mouseY > 250 ) && (mouseY<385)) {
println("blending2");
transparencyMiddle = (int) map(mouseY, 385, 250, 0.0, 255.0);
movieMiddle.loadPixels();
MiddleAlpha.loadPixels();
int x=0;
int y=0;
for (int i = 0; i < MiddleAlpha.pixels.length; i++) {
color myColor = movieMiddle.pixels[i];
MiddleAlpha.pixels[i]= color(myColor, transparencyMiddle);
x++;
if (x>=width) {
x=0;
y++;
}
}
updatePixels();
image (movieBottom, 0, 0);
image(MiddleAlpha, 0, 0);
playheadBottom = map(mouseX, 0, width, 0, movieBottom.duration());
playheadMiddle = map(mouseX, 0, width, 0, movieMiddle.duration());
movieBottom.jump(playheadBottom);
movieMiddle.jump(playheadMiddle);
}
else if (mouseY >384) {
println ("playing bottom");
image (movieBottom, 0, 0);
playheadBottom = map(mouseX, 0, width, 0, movieBottom.duration());
movieBottom.jump(playheadBottom);
}
}
1