I'm trying to make simple slideshow (with or without transition effects) for projection mapping.
I have in processing OutOfMemory problem because 250-300 images (1280x720) have been loaded in setup function.
Then I have found FileSequence example in toxiclibs library
that workspretty well althoughframerate drops dramatically (5-10). What I need is to control appearance of images using minim library and SoundEnergy ( beat.isOnset(), beat.isKick(), beat.isHat(), beat.isSnare() ).
The images would be changed when specific audio parameter exceeds a certain value (
in rhythm).
Welcome with good ideas...
firstattempt:
import processing.opengl.*;
import codeanticode.glgraphics.*;
import toxi.util.*;
import java.awt.FileDialog;
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer song;
BeatDetect beat;
FileSequenceDescriptor fsd;
Iterator images;
String imgPath;
PImage img;
void setup() {
size(1280, 720, GLConstants.GLGRAPHICS);
minim = new Minim(this);
song = minim.loadFile("marcus_kellis_theme.mp3", 2048);
song.play();
// a beat detection object song SOUND_ENERGY mode with a sensitivity of 10 milliseconds
My sketch hangs when I try to load several audio files (minim library), GSCapture video and some glsl filters (GLGRAPHICS)..
Is there a way to avoid this by making some kind of intro (logo image) in startup routine when the data was loading?
Related to this
post I'm attempting to create blobs detection in two rectangular detection areas using Kinect depth information and passing it to a flob detection routine.
For some reason I see the framerate drop dramatically alot of times. And I'm getting only one blob at the same time. I would appreciate any thoughts to improve blob detection..
import SimpleOpenNI.*;
import s373.flob.*;
SimpleOpenNI context;
Flob flob1;
float minThreshold = 1000; // minimum distance from the sensor
float maxThreshold = 1500; // maximum distance from the sensor
color blobNo = color(0); // color if it's outside the range
color blobYes = color(0, 255, 0); // color if it's within the range
int tresh = 250;
int om = 0;
ArrayList blobs1;
void setup() {
size(640, 480);
context = new SimpleOpenNI(this);
if (!context.enableDepth()) {
exit();
return;
}
context.setMirror(true);
context.enableScene();
flob1 = new Flob(context.sceneImage(), context.sceneWidth(), context.sceneHeight());
On the hardware side is a monitor display connected to a rotating mount. Attached to the back of the monitor is a rotary encoder. On the software side is maze processing sketch communicate with arduino which forward the data from rotary encoder to processing sketch.
Boundaries of the maze (full screen mode) would be actually the edges of the screen.
How to ensure that all vertices will be on the right place ? Make all graphics and physics in off-screen buffer and then translate, rotate and place screen buffer in default position ??
BTW, when rotation is faster, green ball penetrates blue fixed rectangle. Is there any way to avoid this?
import fisica.*;
public FWorld world;
public Board board;
public MazeNode[][] nodes;
public ArrayList<FBody> rotateUs;
public FBody body2;
public float mazeAng;
public float mouseAng;
public int offsetX = 0;
public int offsetY = 0;
public PFont font48;
public PFont font36;
public boolean gamePaused = false;
public boolean cursorLeftUnpauseCircle = true;
// constants
public static final int UI_BAR_HEIGHT = 40;
public static final float ROT_SPEED = 0.05; // this can be turned up, because the ball is in rotateUs
public int ROWS = 1;
public int COLS = 1;
public int GAP = 500;
public int rows = ROWS;
public int cols = COLS;
public int gap = GAP;
void setup()
{
size(800, 800);
//size(640,640,P2D); // causes walls to be invisible...?
smooth();
// physics stuff
Fisica.init(this);
world = new FWorld();
//world.setGravity(0, 30);
body2 = new FCircle(50);
body2.setPosition(width/2, height/4);
body2.setFill(50, 255, 50);
body2.setStroke(0);
body2.setStrokeWeight(3);
body2.setRestitution(0);
body2.setFriction(1);
world.add(body2);
reset();
}
public void reset()
{
// stupid hack so changing maze settings in the UI doesn't frak up code (eg - orbiters) that use those settings
ROWS = rows;
COLS = cols;
GAP = gap;
// end stupid hack
// offset values describe blank space between applet edges and the edges of the maze
I'm looking for the best solution for tracking left or right hand with kinect and use them instead of mouse in processing (drawing sketch).
Please if anyone can give valuable suggestion between this five options regarding FPS performance and satisfying precision:
Using set(x, y, color) in GLGRAPHICS mode decrease framerate from 60fps to 10. I have tried also use
pixels[], but result is same.
"Setting the color of a single pixel with
set(x, y) is easy, but not as fast as putting the data directly into
pixels[]. The equivalent statement to "set(x, y, #000000)" using
pixels[] is "pixels[y*width+x] = #000000". You must call
loadPixels() to load the display window data into the
pixels[] array before setting the values and calling
updatePixels() to update the window with any changes."
Please put this code into GLGRAPHICS without loosing performance..
img = loadImage("landscape.jpg"); img.loadPixels(); for (int i = 0; i < 480000; i++) { col[i]=img.pixels[i]; } dest = createImage(800, 600, RGB); dest.loadPixels(); for (int i = 0; i < 480000; i++) { dest.pixels[i]=col[480000-i-1]; } }
void draw() {
for (int i = 0; i < 7000; i++) { int px=int(random(0, 800)); int py=int(random(0, 600)); dest.set(px, py+int(random(0, 1)), color(255, 0, 0)); //dest.pixels[px + 800*(py+int(random(0, 1)))] = #F00000; //dest.updatePixels(); }
void setup() { size(800, 600, GLConstants.GLGRAPHICS); wall = loadImage("Umbrellas1.jpg"); img = loadImage("Raindrops.jpg"); cp = new GLTextureFilter(this, "copy.xml"); // copy source texture to destination texture myFilter = new GLTextureFilter(this, "MouseHole.xml"); // makes hole arround mouse srcTex = new GLTexture(this); destTex = new GLTexture(this); srcTex.putPixelsIntoTexture(img); //destTex.putPixelsIntoTexture(img);
}
void draw() { image(wall, 0, 0);
float x = mouseX; float y = mouseY; myFilter.setParameterValue("mpos", new float[] {x, y} ); myFilter.setParameterValue("mdist", mouseDist); myFilter.apply(srcTex, destTex); image(destTex, 0, 0, width, height);
println(frameRate);
}
TODO:
- blur mouse trail on the edge in first sketch
- add trails in second sketch
- for a few seconds Raindrops image returns to cover up the cleared spots (time-dependent alpha value??)
How could be achieve presentation of multiples sketches, one by one ?
Basically n totaly independent compositions, each displaying different things, each one using different libraries and different rendering engines.
Is processing able to load sketches dynamically based on some rule? What I need is for the compositions to change every n minutes and/or when speciffic data trigger some actions (OSC messages). Of course, I could merge all the code in one file, but then it will become messy. I'd simply like to keep every sketch independent, so they would be more easily to manage etc etc.
The pseudoscript could be:
// a "mastersketch" to load and display other sketches
// global - define paths to sketches, maybe set up some rules for each
void setup()
{
// setup
}
void draw()
{
// Loading and drawing other sketches, based on some rules
// based on time, a fast implementation ;) loads 3 sketches, each one shown for 20 seconds
Here is example to show how sketches in separate windows can talk to each other...
The problem is how to d
isables decorations for both frames and put them on black background (SoftFullScreen - Hansi's fullscreen library for Processing)..
"In this video, circle particles fill the volume of the building and once settled in place, create an image.
The trick here is to render the particle system twice. First, run the simulation and record the colour values of all the balls once they’ve settled and then to render again the second time and since the simulation is identical, the balls fall into the right place with the right colour."
If someone has tried something similar with fisica library in processing, please let me know and post links to anything you think might help me..
Find and print 5 closest objects (represented as 3 numbers) to the given object
database = dbnumbers
table = numbers
One object is represented as:
4 fields (id, C1, C2, C3)
id = INT
C1 = FLOAT
C2 = FLOAT
C3 = FLOAT
C1, C2, C3 are random numbers 0-100
Required object is represented as 3 float values:
certain_number1
certain_number2
certain_number3
1. step
Find the closest numbers to the certain_number1 from a numbers table (field C1)
condition: ABS( C1 - certain_number1 ) <= threshold_value
2. step
Between a list of numbers that are seperated by step 1,
pull of the closest numbers to the certain_number2 from a numbers table (field C2)
condition: ABS( C2 - certain_number2 ) <= threshold_value
3. step
Between a list of numbers that are seperated by step 2,
pull of the closest numbers to the certain_number3 from a numbers table (field C3)
condition: ABS( C3 - certain_number3 ) <= threshold_value
if ( msql.connect() ) { // create a table with an id, C1, C2, C3 msql.execute( "CREATE TABLE IF NOT EXISTS " + table + " ("+"id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, C1 DECIMAL (5,2), C2 DECIMAL (5,2), C3 DECIMAL (5,2))");
// fill the table with some data for(int i=0; i<100; i++){ c_1 = random(100); c_2 = random(100); c_3 = random(100); msql.execute( "INSERT INTO " + table + " (C1, C2 , C3) VALUES (\"" + c_1 + "\", \"" + c_2 + "\", \"" + c_3 + "\")" ); }
// need to find out how many rows there are in table? msql.query( "SELECT COUNT(*) FROM " + table ); msql.next(); println( "number of rows: " + msql.getInt(1) ); } else { // connection failed ! println("connection failed!"); } }
I have found toxiclibscore\examples\geometry\ProfilePathAlignment and I have used it in boid sketch (steering). Everything works fine, but there are moments when Agent flip back and forward very quickly (Agent follow mouse, but when quickly move the mouse in opposite direction, Agent make unnatural movement).
I want to apply SLERP function (Quaternion interpolateToSelf(Quaternion target, float t)).
How to implement it with Quaternion alignment and rotation matrix ??
void display() {
noStroke();
// Rotation vectors
// use to perform orientation to velocity vector
Vec3D new_dir = new Vec3D(velocity);
new_dir.normalize();
Vec3D new_up = new Vec3D(0.0, 1.0, 0.0);
new_up.normalize();
//axis of rotation
Vec3D new_side = new_dir.cross(new_up);
new_side.normalize();
//quaternion that rotates the vector given by the "forward" param into the direction given by the "dir" param.
//public static Quaternion getAlignmentQuat(ReadonlyVec3D dir, ReadonlyVec3D forward)
Quaternion alignment = Quaternion.getAlignmentQuat(
new_dir,Vec3D.Y_AXIS);
//public Matrix4x4 translateSelf(ReadonlyVec3D trans)
Matrix4x4 mat = new Matrix4x4().translateSelf(
mouseX, mouseY, 0);
mat.multiplySelf(alignment.
toMatrix4x4());