Issues with low video frame rate.

Hey guys, I'm having issues with this code (based on 2tung's code: https://forum.processing.org/two/discussion/10531/trouble-clearing-video-image-with-multiple-clips). I am trying to trigger large video files from hotpoints via kinect. The videos launch fine but are running extremely slow, under 10 fps. How can I fix that? Thank you.

Here is the code:

import processing.opengl.*; import SimpleOpenNI.*; //import ddf.minim.*; import processing.video.*; SimpleOpenNI kinect; float rotation = 0; String nowPlaying = ""; // two AudioPlayer objects this time //Minim minim; Movie affiche1_Video; Movie affiche2_Video; // declare our two hotpoint objects Hotpoint affiche1Trigger; Hotpoint affiche2Trigger; float s = 1; void setup() { size(1080, 1920, OPENGL); frameRate(25); kinect = new SimpleOpenNI(this); kinect.enableDepth(); affiche1_Video = new Movie(this, "affiche1.mov"); affiche1_Video.frameRate(25); affiche2_Video = new Movie(this, "affiche2.mp4"); // initialize hotpoints with their origins (x,y,z) and their size affiche1Trigger = new Hotpoint(200, 0, 600, 150); affiche2Trigger = new Hotpoint(-200, 0, 600, 150); } void draw() { println(frameRate); if (nowPlaying =="pointCloud") { background(0); translate(width/2, height/2, -1000); rotateX(radians(180)); translate(0, 0, 1400); rotateY(radians(map(mouseX, 0, width, -180, 180))); translate(0, 0, s*-1000); scale(s); stroke(255); } if (nowPlaying == "affiche1") { image(affiche1_Video, 0, 0); } else if (nowPlaying == "affiche2") { image(affiche2_Video, 0, 0); } kinect.update(); stroke(255); PVector[] depthPoints = kinect.depthMapRealWorld(); for (int i = 0; i < depthPoints.length; i+=10) { PVector currentPoint = depthPoints[i]; // have each hotpoint check to see // if it includes the currentPoint affiche1Trigger.check(currentPoint); affiche2Trigger.check(currentPoint); point(currentPoint.x, currentPoint.y, currentPoint.z); } println(affiche1Trigger.pointsIncluded); if(affiche1Trigger.isHit()) { nowPlaying = "affiche1"; stopVids(); affiche1_Video.play(); } if (affiche2Trigger.isHit()) { nowPlaying = "affiche2"; stopVids(); affiche2_Video.play(); } // display each hotpoint // and clear its points affiche1Trigger.draw(); affiche1Trigger.clear(); affiche2Trigger.draw(); affiche2Trigger.clear(); } void keyPressed() { if (keyCode == 38) { s = s + 0.01; } if (keyCode == 40) { s = s - 0.01; } } void movieEvent(Movie m) { if (nowPlaying == "affiche1") { affiche1_Video.read(); } else if (nowPlaying == "affiche2") { affiche2_Video.read(); } } void stopVids() { if (nowPlaying == "affiche1") { affiche2_Video.stop(); } else if (nowPlaying == "affiche2") { affiche1_Video.stop(); } } 
submitted by /u/solar_groove
[link] [comments]

Can anyone write this? I need something to study, I would like to find the difference in my code.

Create the box using 4 rectangles for the 4 sides of the box. The box begins closed. When the user clicks on the button, the lid of the closed box will open, with a counter-clockwise rotation. Note: clicking outside the button should do nothing! The center of rotation of the lid is at the top, left point of the box. When the lid opens, the interior of the box changes from gray to blueish. When the lid closes, the interior of the box changes from blueish to gray. The lid doesn't rotate further than 180 degrees. When the user clicks on the button when the box is open, the lid closes. The button is a circle, with two lines used to reveal rotation. When the lid is opening or closing, the button rotates - in the opposite direction from the lid. Our standard requirements for all sketches still apply The sketch must run with no warning or error messages. The sketch must be properly formatted, with standard spacing and indentation, and good use of names.

submitted by /u/KamStorm
[link] [comments]

How start to explore growing networks

Hello,

I'm new to processing and want to use it to mess around by creatively coding simple growing networks in 2D - like bacteria growing in a petri dish but instead of being blobby, just a triangular structure to randomly grow from a point but then clicking on the canvas in various points would create attractor points (like food or something). Eventually, it'd be cool to put a Black&White/grayscale image background where black is more attractive than white (or vice versa) and see how it grows. And then as I am learning processing, I can add other things... I guess I'm stuck at how to start this - are there any tutorials with similar ideas that I could check out?

Thanks for any help!

submitted by /u/GreenPens
[link] [comments]

How can I make this musical staff work?

I'm trying to make it so when I click on the staff, a musical note appears. However, when the mouse is clicked, I want it so the note can only be either on the lines or in between the lines and I don't want the note to be able to be placed outside of the musical staff lines. How would I go about doing this? It's just for a personal project. Also is what I've done so far (to set up the musical staff as a static), coded correctly? Is there any improvements I can make to the current code in order to make it neater/easier to read? Any feedback is welcome. Thank you!

This is the code:

void setup() {
size(520, 160);
background(255);

int x1 = width * 2/100;
int x2 = width * 96/100;
int y1 = height/4;
int y2 = height/2;
int y3 = height/2-height/8;

fill(0);
rect (x1, y1, x1, y2);
rect (x2, y1, x1, y2);

noFill();
rect (x1, y1, x2, y1);
rect (x1, y2, x2, y1); rect (x1, y3, x2, y1);
}

submitted by /u/Exoski
[link] [comments]

Help with Frogger Assignment

Hey guys, I started a assignment for class today on a frogger program that puts an emphasis on arrays.

I have most of the program complete as of right now, I just need to add collision which I can do fast. The problem I have is the squares(placeholder) are clipping into each other, I've tried a few things but I haven't been able to fix this problem without creating ridiculous spaces or braking it completely,

This is the code as of right now;

//J--- S-------- //March 29, 2016 //Cars in Different lanes //Declaring Varibles float x [] = new float [13]; //X-variable for cars in lane 1 float x2 [] = new float [13]; //X-variable for cars in lane 2 float x3 [] = new float [13]; //X-variable for cars in lane 3 float x4 [] = new float [13]; //X-variable for cars in lane 4 float speed = 4; //speed variable for the cars float r[] = new float [13]; //variable for the colour red float g[] = new float [13]; //variable for the colour green float b[] = new float [13]; //variable for the colour blue int lane1 = 100; //Y-variable for the cars in lane 1 int lane2 = 200; //Y-variable for the cars in lane 1 int lane3 = 300; //Y-variable for the cars in lane 1 int lane4 = 400; //Y-variable for the cars in lane 1 int k=400, j=450; // varriable for the user controlled character void setup () { size(800, 500); frameRate(60); smooth(); x[0]=800; //starting values of cars in lane 1 x2[0]=800; //starting values of cars in lane 2 x3[0]=800; //starting values of cars in lane 3 x4[0]=800; //starting values of cars in lane 4 strokeWeight(.5); rectMode(CENTER); for (int a=1; a<x.length; a++) { x[a]=x[a-1]-random(50, 150); //Spacing between cars in lane 1 x2[a]=x2[a-1]-random(50, 150); //Spacing between cars in lane 2 x3[a]=x3[a-1]-random(50, 150); //Spacing between cars in lane 3 x4[a]=x4[a-1]-random(50, 150); //Spacing between cars in lane 4 r[a]=random(50, 255); g[a]=random(50, 255); b[a]=random(50, 255); } } void draw () { background(255); //grass fill(125, 200, 125); rect(400, 500, 1800, 150); //road fill(125, 125, 120); rect(400, 350, 1800, 150); //lines fill(255, 255, 0); rect(400, 350, 1800, 3); //grass fill(125, 200, 125); rect(400, 250, 1800, 65); //water fill(0, 0, 200); rect(400, 145, 1800, 160); //grass fill(125, 200, 125); rect(400, 30, 1800, 85); //User controlled character if (keyPressed) { if (key==CODED) { if (keyCode==RIGHT) k=k+3; if (keyCode==LEFT) k=k-3; if (keyCode==DOWN) j=j+3; if (keyCode==UP) j=j-3; } } //User controlled Square fill(255, 255, 125); rect(k, j, 20, 20); for (int a=1; a < x.length; a++) { //Moving the cars x[a]=x[a]+speed; x3[a]=x3[a]+speed; //Fill colours fill(r[a], g[a], b[a]); //drawing the cars rect(x[a], lane1, 30, 20); rect(x2[a], lane2, 30, 20); rect(x3[a], lane3, 30, 20); rect(x4[a], lane4, 30, 20); //Reseting the cars if (x[a]>width+50) { x[a]=x[a]+random(-870, -1400); } if (x2[a]<-50) { x2[a]=x2[a]+random(900, 1400); } if (x3[a]>width+50) { x3[a]=x3[a]+random(-870, -1400); } if (x4[a]<-50) { x4[a]=x4[a]+random(900, 1400); } } //Moves cars the other direction in lane 2 & 4 for (int a=1; a < x.length; a++) { x4[a]=x4[a]-speed; x2[a]=x2[a]-speed; } if ( j <= 40) { textSize(36); fill(255, 255, 0); text("You Won!", 295, 270); frameRate(0); } } 

I've look at other examples, but everyone seems to do things differently. I would ask my teacher but I'd rather not wait till Monday.

submitted by /u/XheadJr
[link] [comments]

Help with video.size() issue

I was attempting to model this tutorial: https://www.youtube.com/watch?v=rNqaw8LT2ZU

However, when I tried running the code below, the 'video of pixels' would load the full resolution of my webcam rather than the sized 1/16 low res recording. I can't see whats the issue and I'm pretty new to p5.js

var video;

var vScale = 16;

function setup() { createCanvas(640, 480); pixelDensity(1);

video = createCapture(VIDEO);

video.size(width / vScale, height / vScale); }

function draw() { background(51);

video.loadPixels();

loadPixels();

for (var y = 0; y < video.height; y++) {

for (var x = 0; x < video.width; x++) {

var index = (x + y * video.width) * 4;

var r = video.pixels[index + 0];

var g = video.pixels[index + 1];

var b = video.pixels[index + 2];

var bright = (r + g + b) / 3;

fill(bright);

rect(x * vScale, y * vScale, vScale, vScale);

} }

}

submitted by /u/herringblue
[link] [comments]

Help with video.size() issue

I was attempting to model this tutorial: https://www.youtube.com/watch?v=rNqaw8LT2ZU

However, when I tried running the code below, the 'video of pixels' would load the full resolution of my webcam rather than the sized 1/16 low res recording. I can't see whats the issue and I'm pretty new to p5.js

var video;

var vScale = 16;

function setup() { createCanvas(640, 480); pixelDensity(1);

video = createCapture(VIDEO);

video.size(width / vScale, height / vScale); }

function draw() { background(51);

video.loadPixels();

loadPixels();

for (var y = 0; y < video.height; y++) {

for (var x = 0; x < video.width; x++) {

var index = (x + y * video.width) * 4;

var r = video.pixels[index + 0];

var g = video.pixels[index + 1];

var b = video.pixels[index + 2];

var bright = (r + g + b) / 3;

fill(bright);

rect(x * vScale, y * vScale, vScale, vScale);

} }

}

submitted by /u/herringblue
[link] [comments]