我正在制作影片剪辑操作,让视频逐点显示但卡住了。 这是代码:
import processing.video.*;
Movie video;
int pointillize = 16;
void setup() {
size(640,360);
video = new Movie(this,"dynamic.mov");
video.loop();
}
void movieEvent(Movie video){
video.read();
}
void draw() {
if (video.available()) {
video.read();
}
loadPixels();
video.loadPixels();
int x = int(random(video.width));
int y = int(random(video.height));
int loc = x + y*video.width;
float r,g,b;
r = red (video.pixels[loc]);
g = green (video.pixels[loc]);
b = blue (video.pixels[loc]);
color c = color(r,g,b);
pixels[loc] = c;
fill(r,g,b,100);
ellipse(x,y,pointillize,pointillize);
}
问题是我认为的问题。谁能告诉我如何解决这个问题?感谢。
答案 0 :(得分:1)
您需要在加载的视频中使用相同数量的像素[loc]以及草图大小。错误告诉您数组无法匹配您请求的像素。
我在这里尝试了它并且它的工作原理,将尺寸改变为大小(1920,1080);并使用1920x1080的视频来匹配它。
import processing.video.*;
Movie video;
int pointillize = 16;
void setup() {
size(1920,1080);
video = new Movie(this,"break.mov");
video.loop();
}
void movieEvent(Movie video){
video.read();
}
void draw() {
if (video.available()) {
video.read();
}
loadPixels();
video.loadPixels();
int x = int(random(video.width));
int y = int(random(video.height));
int loc = x + y*video.width;
float r,g,b;
r = red (video.pixels[loc]);
g = green (video.pixels[loc]);
b = blue (video.pixels[loc]);
color c = color(r,g,b);
pixels[loc] = c;
fill(r,g,b,100);
ellipse(x,y,pointillize,pointillize);
}