xxxxxxxxxx
var img;
var x = 0;
var y = 0;
let table;
function setup() {
c = createCanvas(2000, 720);
background(0);
vid = createVideo("220427_Zeitraffer.mp4")
vid.size(2000, 720)
vid.play();
vid.hide();
interval = setInterval(draw, 1000);
/// Table
table = new p5.Table();
table.addColumn('pixel0');
table.addColumn('pixel1');
table.addColumn('pixel2');
table.addColumn('pixel3');
table.addColumn('pixel4');
}
function draw() {
//background(255);
//image(img, mouseX, 0);
// Pixel in Speicher laden
//img.loadPixels();
vid.loadPixels();
image(vid, 0, 0);
//img.updatePixels();
//var line = vid.get(vid.width / 2, 0, 1, vid.height);
//a = img.height/5
a = height / 1 // Number of pixels
pixel0 = vid.get(vid.width / 2, a * 0.5);
pixel1 = vid.get(vid.width / 2, a * 1.5);
pixel2 = vid.get(vid.width / 2, a * 2.5);
// move to the next position x
translate(x, 0);
noStroke();
fill(pixel0);
rect(x, 0, x + 1, a * 1);
fill(pixel1);
rect(x, a * 1, x + 1, a * 2);
fill(pixel2);
rect(x, a * 2, x + 1, a * 3);
fill(0)
if (interval += 1) {
let newRow = table.addRow();
newRow.setString('pixel0', pixel0);
newRow.setString('pixel1', pixel1);
newRow.setString('pixel2', pixel2);
}
// increment the position x or set to zero (at the end)
if (x < width) {
x += 1; // += 2 -> Spationierung / Speed
}
else {
x = 0;
//saveCanvas(c, 'screenshot', 'jpg');
}
}
function keyPressed() {
if (key == "s") {
saveTable(table, 'new.csv');
}
if (key == "c") {
//save('new.png');
}
}