Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all 2896 articles
Browse latest View live

I just installed Processing and the program does not recognize serial variables like OUTPUT.

$
0
0

Where is the library for the serial functions? What is it called.


using gstreamer in eclipse

$
0
0

Im trying to use GStreamer in eclipse via jna. Processing provides a library for that and all is fine if i try to run the code by running the sketch as an applet from eclipse, but when i try to execute the whole application i get a list of warnings(on Camera first call) like this one

(javaw.exe:3840): GStreamer-WARNING **: Failed to load plugin 'C:/Users/aaa/Desktop/bbb/ccc/video/library/\windows64\plugins\libgstvorbis.dll': `C:/Users/aaa/Desktop/bbb/ccc/video/library/\windows64\plugins\libgstvorbis.dll': Impossibile trovare il modulo specificato.

on 30+ of 140 plugins (probably the ones needed by my library for the camera managment)

the jna jar and the libraries are in the project folder C:/Users/aaa/Desktop/bbb/ccc/video/library/ and included in the build path

and the native code is in C:/Users/aaa/Desktop/bbb/ccc/video/library/windows64/plugins/

the path doesnt seem correct, note the /\ after library

i never wrote libraries that need jna and i was trying to use this library as is if possible, any suggestions?

how i can display live feed through camera and display particular movie on marker detection?

$
0
0

multiple marker and multiple videos and also when video stop the live camera feed continue and then marker detect and play video and so on..

Jasmine question

$
0
0

Hello All,

I am using Jasmine (Peter Lager's aka Quarks) Java expression evaluation library for a little project. But I am getting a java.lang.NullPointerException on the line that compiles the expression :

Expression e = Compile.expression(anExpr, false);

The programme calls the method containing this statement several times, in fact the particular expression has already been evaluated in a different call to the method (I know I need to optimise it). The point is it works every previous time but for this occurrence (possibly the 20th time or so that the statement is ran) it gives an error.

Further testing :

1) The expression used doesn't cause it (I've tried different ones) 2) I can call the method that contains the statement 4 times but on the fifth it crashes.

Some sort of memory fault (should I be doing something to the objects used)?

Minim

$
0
0

I'm using the minim Library for the means of initiating sound. Now I am trying to pause the song whenever the user clicks on the white square however there is something wrong because as I click on the background it pauses and restarts instead of continuing. Any help? please.

import ddf.minim.*; import ddf.minim.analysis.*;

Minim minim; AudioPlayer song; boolean isMute = false;

void setup(){ size(500,500); background(0); minim = new Minim(this); song = minim.loadFile("portal.mp3", 1024); song.play(); }

void draw(){ background(0); rectMode(CENTER); rect(width/2,height/2,100,100);

}

void mousePressed(){ if(mouseX < width/2 && mouseY < height/2){ song.pause(); } else{ song.loop(); } }

Question about processing using Leap Motion

$
0
0

Hi everyone! I'm currently trying to develop a processing app using Leap Motion for a uni project. The app that I'm trying to do is an image where it show various animals and if the user uses the leap motion to hover over the animal, it will then play the sound of the animal.

I've managed to get the mouse coordinates so it would be easier to know where the coordinates for each animal are, I also added an ellipse where I want these animals to be at. But it seems that once I use the leap to look for the sound and when I hover over the animal won't work as the coordinates suddenly are somewhere else in the screen.

I even tried to make the image resolution the same size as mine instead of trying to go for a default to present at uni.

Is there a way to add an invisible hit box that will activate with the leap movement, instead of adding the coordinates to the fingerPosition.x/y.

I've tried multiple things, but can't find the solution. Can anyone spot where the issue is?

Thank you

    import ddf.minim.spi.*;
    import ddf.minim.signals.*;
    import ddf.minim.*;
    import ddf.minim.analysis.*;
    import ddf.minim.ugens.*;
    import ddf.minim.effects.*;

    import de.voidplus.leapmotion.*;
    LeapMotion leap;
    // Declaring the mp3 file function things
    Minim minim;


    AudioPlayer[] playlist;
    AudioPlayer player;

    PImage img;
    PImage img2;
    //A true or false variable to determine whether the menu screen should be active or not
    boolean menu = true;
    //Feel free to change the size to anything, it should still work
    int size = 750;
    //declaring the color arrays

    float INTERACTION_SPACE_WIDTH = 200; // left-right from user
    float INTERACTION_SPACE_DEPTH = 150; // away-and-toward user
    float FINGER_DOT = 30;



    void setup () {
      size(displayWidth, displayHeight, P3D);
      img = loadImage("farmmenuDMF.png");
      img2 = loadImage("farmDMF2.png");
      background(0);
      minim = new Minim(this);
      noStroke(); fill(50);
      leap = new LeapMotion(this);
      //defining the mp3 names and assigning them to reference items
      playlist = new AudioPlayer [6];
      playlist[0] = minim.loadFile("cat.wav"); //cat
      playlist[1] = minim.loadFile("dog.wav"); //dog
      playlist[2] = minim.loadFile("chicken.wav"); //chicken
      playlist[3] = minim.loadFile("pig2.wav"); //pig
      playlist[4] = minim.loadFile("chicken.wav"); //sheep
      playlist[5] = minim.loadFile("dog.wav"); //cow
    }

    void draw() {
      background (255);
      //the call to the leapFunction
      leapFunction ();

      image(img2, 0, 0);

      fill(234,86,250); //pink/cat
      ellipse(1200, 350, 120,80);//cat
        fill(255,0,0); //red/dog
      ellipse(322, 337, 100,100);
      fill(241,253,72); //yellow/chicken
      ellipse(1126, 659, 100,100);
      fill(0,255,0); //green/pig
      ellipse(473, 447, 150,150);
      fill(255,0,255); //sheep
      ellipse(328, 591, 150,150);
      fill(0,0,255); //blue/cow
      ellipse(814, 469, 180,180);


      //The start Screen:
      if(menu == true) {
        image(img, 0, 0);
        fill(150);
        rect(560,600,100,50);
        fill(0);
        text("Play", 593, 630);
        if ( mousePressed == true && mouseX > 510 && mouseX <  610 && mouseY > 550 && mouseY < 650){
          menu = false;
        }
      }
       int fps = leap.getFrameRate();
      fill(#00E310);
     text(fps + " fps", 20, 20);

      for (Hand hand : leap.getHands ()) {

        PVector indexTip = hand.getIndexFinger().getRawPositionOfJointTip();

        handleFinger(indexTip," ");
      }
      ellipse( mouseX, mouseY, 2, 2 );
      fill(0);
      text( "x: " + mouseX + " y: " + mouseY, mouseX, mouseY );

    }

    void handleFinger(PVector pos, String id) {

     // map finger tip position to 2D surface
      float x = map(pos.x, -INTERACTION_SPACE_WIDTH,
      INTERACTION_SPACE_WIDTH, 0, width);
      float y = map(pos.z, -INTERACTION_SPACE_DEPTH,
      INTERACTION_SPACE_DEPTH, 0, height);
      fill(#00E310);
      noStroke();
      ellipse(x, y, FINGER_DOT, FINGER_DOT);
    }


    //Leap function that senses finger position and assigns it to the keys
    void leapFunction () {

      //int finger_positions = leap.getFrameRate();

      // HANDS
      for(Hand hand : leap.getHands()){


        // FINGERS
        for(Finger finger : hand.getFingers()){

          // Basics
         //finger.draw();
          //int     finger_id         = finger.getId();
          PVector finger_position   = finger.getPosition();


            if(finger_position.x > 1160 && finger_position.x < 1200 && finger_position.z > 300 && finger_position.z < 380 ){   //cat
          playlist[0].play();

           }
          else
         playlist[0].pause();
        /*
        if (finger_position.x > 300 && finger_position.x < 350 && finger_position.y > 300 && finger_position.y > 300 && finger_position.y < 380) { //dog
          playlist[1].play();
        }
        else
          playlist[1].pause();

        if (finger_position.x > 1070  && finger_position.x < 1080 &&  finger_position.y < 715) { //chicken
          //playlist[2].play();
        }
        else
          playlist[2].pause();

        if (finger_position.x > 390 && finger_position.x < 550 && finger_position.y < 525) { //pig
          playlist[3].play();
        }
        else
          playlist[3].pause();

        if ( finger_position.x > 250 && finger_position.x < 400 &&  finger_position.y < 670){ //sheep
         playlist[4].play();
        }
        else
          playlist[4].pause();

          if ( finger_position.x > 720 && finger_position.x < 900 &&  finger_position.y < 560){ //cow
         playlist[5].play();
        }
        else
          playlist[4].pause(); */

          // Touch Emulation
          int     touch_zone        = finger.getTouchZone();
          //float   touch_distance    = finger.getTouchDistance();

          switch(touch_zone){
            case -1: // None
              break;
            case 0: // Hovering
              // println("Hovering (#"+finger_id+"): "+touch_distance);
              break;
            case 1: // Touching
              // println("Touching (#"+finger_id+")");
              break;
          }
        }
      }
        }

    void stop()
    {

      minim.stop();
      //super.stop();
    }

big bang theory

$
0
0

Hello everyone; I am trying to create a simulation for Big Bang Theory. I would like to create a sphere in the middle then make it explode and then I would like to create the sun(as a new sphere) and the solar system.

I tried my best but something is definitely not working as I want. I would appreciate If you guys can help me. It is very urgent since it is my final project.

import peasy.org.apache.commons.math.geometry.*;

PeasyCam cam; Planet sun; Particle [] particles = new Particle [800]; Sun mySun;

void setup () {

size (700, 700, P3D); smooth (); cam = new PeasyCam(this, 700); sun = new Planet(40, 0, 0); sun.spawnMoons(3, 1); for (int i=0; i<particles.length; i++) { particles [i] = new Particle (); }

mySun = new Sun(); }

void draw () { background (0); //clear the background for (int i=0; i<particles.length; i++) { particles[i].update(); } float time= millis(); if (millis() > 5500) { mySun.display(); time= millis (); }

if ( millis() >7500) { lights(); sun.display(); sun.orbit(); time= millis(); } }

class Particle {

float x; float y;

float aX; // speed float aY;

Particle () { //x and y position to be in middle of screen x = width/2; y = height/2;

aX = random (-10,10);
aY = random (-10,15);

}

void update () {

x+=aX;
y+=aY;

fill (255);
ellipse (x,y,7,7);

} }

class Planet { // solar system works as I want float radius; float distance;

Planet[] planets; float angle; float orbitspeed; PVector v; PShape globe;

Planet(float r, float d, float o) {

v = PVector.random3D();

radius = r;
distance = d;
v.mult(distance);
angle = random(PI-45);
orbitspeed = o;

}

void orbit() { angle = angle + orbitspeed; if (planets != null) { for (int i = 0; i < planets.length; i++) { planets[i].orbit(); } } }

void spawnMoons(int total, int level) { planets = new Planet[total]; for (int i = 0; i < planets.length; i++) { float r = radius/(level2); float d = random((radius + r), (radius+r)2); float o = random(-0.1, 0.1); planets[i] = new Planet(r, d, o); if (level < 2) { int num = int(random(0, 3)); planets[i].spawnMoons(num, level+1); } } }

void display() { pushMatrix(); noStroke(); PVector v2 = new PVector(1, 0, 1); PVector p = v.cross(v2); rotate(angle, p.x, p.y, p.z); stroke(255);

translate(v.x, v.y, v.z);
noStroke();
fill(170);
sphere(radius);
if (planets != null) {
  for (int i = 0; i < planets.length; i++) {
    planets[i].display();
  }
}
popMatrix();

} } class Sun { // the sphere I want to explode

void display(){ lights();

pushMatrix(); translate(350, 350, 0); noStroke(); fill(255); sphere(40); popMatrix(); } }

How to properly use filters with video capture? problem with flickering

$
0
0

I'm trying to apply filter() to live video and found some strange effects. It may be that I have simply missed some documentation, which would be great to see. Can anyone let me know why these different effects are occurring?

Thanks everyone,

Woody

The code below works fine to just display the plain video, here is a list of effects noticed when different lines after image(cam, 0, 0); are uncommented:

   filter(INVERT);

inverts the colours of the image as expected

filter(THRESHOLD,0.5);

shows a black/white image as expected

vid.filter(THRESHOLD);

Shows a black/white image. This is strange because I haven't modified the variable cam. I expected any change made to variable vid not to effect variable cam, however they appear to only be pointers perhaps? Is it possible to make an actual new copy of the video and modify them with separate filters?

cam.filter(INVERT);

gives a fast flickering grey image, with occasional visible inverted and non inverted frames. I expected this to work in the same way as filter(INVERT); I don't understand what is going on here?

vid.filter(INVERT);

Same as cam.filter(INVERT)

Factors that don't change the effects:

changing render from P3D to P2D or the default changing the frame rate and/or resolution of the video (at first I suspected that it might be an issue of CPU power but this would suggest that isn't the problem)

import processing.video.*;
PImage img;

Capture cam;

void setup() {
  size(540, 540, P3D);

  String[] cameras = Capture.list();

  if (cameras.length == 0) {
    println("There are no cameras available for capture.");
    exit();
  } else {
    println("Available cameras:");
    for (int i = 0; i < cameras.length; i++) {
      println(cameras[i]);
    }

    // The camera can be initialized directly using an
    // element from the array returned by list():
    cam = new Capture(this, cameras[2]);
    cam.start();
  }
}

void draw() {

  if (cam.available() == true) {
     cam.read();
  }

   PImage vid=cam;


  image(cam, 0, 0);


  // filter(INVERT);
  // filter(THRESHOLD,0.5);
  // vid.filter(INVERT);
  // vid.filter(THRESHOLD);
  // cam.filter(INVERT);


}

Having font issue with ControlP5 GUI library

$
0
0

I am having an issue with setting the font of the DropdownList items, I know how to edit the font of the caption labels but can't figure out how to do the same for the items in the menu. I really need to make the font bigger as it is so tiny I am struggling to read it on my screen, and that means the end user will have just as hard of a time.

What I have done to change the font of the labels is:

ControlP5 main = new ControlP5(this);
ControlFont font = new ControlFont(createFont("Arial", 18, true), 241);
//^^^^ For reference

main.getController("Select_Vehicle")    // <- Select_Vehicle is a button, this is just a reference to how I have done it so far
    .getCaptionLabel()
    .setFont(font)
    .toUpperCase(false)
    .setSize(14);

This works very well for things that only have labels, but this will not change the font for the items in the dropdown menu. What I thought was maybe I need to replace the .getCaptionLable() with something similar that grabs the items from the menu and allows me to then change it, but what I have tried never worked, then again I haven't been able to try much.

Can't run the sketch with processing.sound

$
0
0

So, I've been searching around the web about this, and I found some solutions, but seems like none worked (reinstall Processing, move the sketch folder somewhere else, and I've seen the Minim library, but I would prefer to use processing.sound).

I actually got it working yesterday, but today it's saying again: Target VM failed to initialize.

So, pretty much I can recreate this with the code below.

import processing.sound.*;
WhiteNoise noise;

void setup() {
  size(800, 600);
  background(255);

  noise = new WhiteNoise(this);
  noise.play();
}

Here's the log, if it helps. http://pastebin.com/LrYq4Kcy

how to reduce flickering in video??

$
0
0

When i am taking canvas size 1280,720 the video is flickering so tell me how to remove that.

2d GUI Libraries

$
0
0

My stick and circle figures for speedometers, elevations, compass, etc are getting boring. Can someone steer me to some 2d graphic libraries that I might use to make my stuff a bit fancier? I am developing a railroad monitoring system that will have a speedometer, grade, elevation, curvature, etc.

Explosion

$
0
0

Hello everyone; I have created a sphere in 3d and shake it randomly. now I would like to make it explode but I couldn't find out how. Can you help me please?

float x, y; void setup () { size (700, 700, P3D); //Im working in 3D so i added P3D smooth (); cam = new PeasyCam(this, 700); x=10; y=10; } void draw () { background (0); lights();

pushMatrix(); translate(x, y); noStroke(); fill(255); sphere(40); popMatrix();

x += random(-5, 5); y += random(-5, 5); }

Plot camera course and make it glide from one point to the other

$
0
0

As the title says I am trying to plot a certain course for a camera to move around a 3D space. In a way that after a certain amount of time it would glide from the first plotted XYZ to another one.

I've looked up moveEye examples and believe it is not what I am looking for. I was just wondering if anyone could direct me towards a resource, a library or generously throw some code at me.

Much appreciated.

Playing processing animation over video

$
0
0

Hi,

I've been curious if it's at all possible to write an animation in processing and then play it over a video with both of them running simultaneously.

It would look almost like this:

Thanks for the help! Neil


How can I play the pixels of a live video with sound input?

$
0
0

Can I use the microphone or beats of a song as an input to change or paint a live video? I want to play with pixels by sound input. Is it possible?

Create a circular display window inside the main one

$
0
0

Hi! I'm a beginner. I'm trying to create a circular shaped display window inside the main window so that I can generate graphics inside using controls from controlP5 library and graphics get cropped automatically in the circular shape. I got familiar with PGraphics but it only generates squared windows... is it possible to change the shape of the window? Or maybe you have a workaround for the same problem. Thank you in advance!

How to make a video start on a full second at 1000 milliseconds...

$
0
0

I'm struggling to understand how to set the parameter so the sketch I've created starts at a full second.

The majority of components including a moving clock, movie and music all need to sync to the same time. However, currently the clock is running to actual time, and the movie and music start immediately from when the user would click 'Run'.

I understand and have used many time framed parameters within my coding, for example draw an ellipse at a certain time such as:

  if (millis() < 24610) {
    fill(255, 255, 0);
    stroke(255, 255, 0);
    strokeWeight(2);
    ellipse(width/2-140, height/2*k+140, 10, 10);
}

I just don't understand how to get a movie or song to play at the certain time, in order for everything to sync to your computers time (as the clock does)...

Could I use some part of the following statement?

  if (movie.available() == true) {
    movie.read();
  }

However add something like... if millis() is 1000 start movie and music...

Sorry, I am still very new to Processing and would appreciate the help a lot!

Thanks,

bmz

oscmessaging speed

$
0
0

hi i need to send an oscmessage to another program. I need to have it go faster than a loop in the draw method. but if i do it in the normal way it is too fast. Since i am using controlP5 i cant use delay() in the loop. I can't find anyway to slow down a loop without using draw and millis().

HiVis sketch pulling xlsx file gives NullPointerException?

$
0
0

Hi, more or less complete novice here; please point me elsewhere if this is the wrong place to ask...

Using the HiVis libraries, I'm trying to build a sketch that will pull coordinate info from a spreadsheet in my sketch's data folder and draw dots on a square at those coordinates. I've got a working sketch using selectInput that asks a user to select the xlsx file, but when I sub in the suggested line for pulling a file from the data folder, I get a nullPointerException at that line, java hangs (I have to force quit it) and I get this text:

Could not run the sketch (Target VM failed to initialize). For more information, read revisions.txt and Help → Troubleshooting.

Any idea what I'm doing wrong?

I found the suggested lines here (commented out, midway down page): https://github.com/OliverColeman/hivis/blob/latest/examples/examples/HV02_Tables/HV02_Tables.pde

Broken sketch:

import hivis.common.*;
import hivis.data.*;
import hivis.data.reader.*;
import hivis.data.view.*;
import hivis.example.*;

// Pulls coordinate info from a spreadsheet and draws the coordinates as white dots on a black 180 x 180 square.

// Stores the data to plot.
DataTable data;

// The series containing the data we want to plot.
DataSeries xSeries;
DataSeries ySeries;

// Method containing one-off setup code.
void setup() {
  // Make a canvas that is 180 pixels wide by 180 pixels high.
  size(180, 180);
  // Pull a spreadsheet from the sketch/data folder.
  DataTable data = HV.loadSpreadSheet(new File("center_coord100_2.xlsx"));
  // The series containing the data we want to plot.
  xSeries = data.getSeries(1);
  ySeries = data.getSeries(2);
}



// Draws the plot.
void draw() {
  background(0);

  // If the data is ready to plot.
  if (ySeries != null) {

    // Gather info from each row.
    for (int row = 0; row < data.length(); row++) {

      // Get values from the series.

      int x = xSeries.getInt(row);
      int y = ySeries.getInt(row);

      // Draw a dot.
      noStroke();
      fill(255);
      ellipse(x, y, 14, 14);
    }
  }
}

Working sketch:

import hivis.common.*;
import hivis.data.*;
import hivis.data.reader.*;
import hivis.data.view.*;
import hivis.example.*;

// Pulls coordinate info from a spreadsheet and draws the coordinates as dots on a 180 x 180 square.

// Stores the data to plot.
DataTable data;

// The series containing the data we want to plot.
DataSeries xSeries;
DataSeries ySeries;

// Method containing one-off setup code.
void setup() {
  // Make a canvas that is 180 pixels wide by 180 pixels high.
  size(180, 180);
  // Ask the user to select a spreadsheet to visualise.
  selectInput("Select an excel file to visualise:", "fileSelected");
}


// Method that gets called when a file is selected.
void fileSelected(File selection) {
  // If no file was selected.
  if (selection == null) {
    println("No file selected.");
  } else {
    // Get data from spread sheet.
    // The SpreadSheetReader will automatically update the DataTable it provides if the source file is changed.
    data = HV.loadSpreadSheet(selection);

    // Get the series containing the data we want to plot.
    xSeries = data.getSeries(1);
    ySeries = data.getSeries(2);
  }
}


// Draws the plot.
void draw() {
  background(0);

  // If the data is ready to plot.
  if (ySeries != null) {

    // Gather info from each row.
    for (int row = 0; row < data.length(); row++) {

      // Get values from the series.

      int x = xSeries.getInt(row);
      int y = ySeries.getInt(row);

   // Draw a dot.
      noStroke();
      fill(255);
      ellipse(x, y, 14, 14);
    }
  }
}

Thank you!!

Viewing all 2896 articles
Browse latest View live