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

simpleOpenNi body tracking doesn't work on mavericks!

$
0
0

Hi, everybody,

I was very surprised when I detected that upgrading to mavericks osx has not been a good idea. The collateral damage is, by the moment, the fact that when I try to run a sketch based on the simple openni user 3d sketch, it doesn't work. It does not even start. I think that simple openni is not entirely compatible with mavericks, does it? I really would appreciate any comment about this issue, I'm developing a project totally based on body tracking with kinect.

Thank you in advance, rojele


PS3 controller on Macbook does not show up in the Game Control Plus library

$
0
0

Hi guys!

I am trying to control an Arduino based rescue robot with a playstation 3 controller through processing, but somehow processing is not able to 'see' the ps3 controller. I did manage to link the controller to my laptop (2014 macbook pro with MacOs Sierra) via bluetooth. And also when I run Enjoy2 (program to map ps3 buttons), it does work perfectly. So there is no question whether the ps3 is connected and working.

But when I am running the example sketch ShowDevices.pde from the Game Control Plus library in Processing, the ps3 controller does not show up. I am using processing 3.1.2 btw. I have searched the whole internet for a solution, but as far as I know, nobody has tried to connect a ps3 controller to processing with the latest macOS. I am wondering if somebody knows how to solve this problem, or, if there is an other way to read and process the input from a ps3 controller with processing (wired or via bluetooth).

with kind regards, Bas

Video Library, not playing mkv files...

$
0
0

hi everybody, i have some big mkv files on my pc and i want to play them with processing video library, but there seems to a problem as nothing happens! i can open them with my players, so i don't think its about files. thanks :-)

Processing tts (Text to speech) with google

Using the google calendar api

$
0
0

Is it possible to use the Google calender api in processig? I mean usig ical/ics in Processing.

Does anyone knows how can Processing compare two frequencies?

$
0
0

Hello I´m developing a project for my university called "The color of music". And I was wondering if there is a tool in processing that can compare the frequency of a song (that already exists) and the frequency of a color. With this, the idea is to display the color in a group of LEDs using wiring. Thank you.

cp5 textArea multiline

$
0
0

Hello.

I wants to show text in the Textarea ouput in mode multiline: every time I press Return on TextField input shows a different line but don't work! any solution? please : )


import controlP5.*;

ControlP5 cp5;

String textValue = "";

Textfield input; Textarea output;

StringList script;

int index = 0; void setup() { size(1000,700, P3D); frameRate(15);

PFont font = createFont("arial",20);

cp5 = new ControlP5(this);

script = new StringList();

input = cp5.addTextfield("input") .setColor(color(0)) .setColorBackground(color(255,255,255,29)) .setColorCursor(color(0)) .setPosition(10,10) .setSize(980,40) .setFont(font) .setFocus(true) ;

output = cp5.addTextarea("output") .setColor(color(0)) .setColorBackground(color(255,255,255,29)) //.setColorCursor(color(0)) .setPosition(10,70) .setSize(980,600) .setFont(font) ;

}

void draw() { background(255);

}

void controlEvent(ControlEvent theEvent){ index = index + 1; textValue = input.getText(); //println(textValue); script.append(textValue); String item = script.get(index-1); item +=item + "\n"; output.setText(item + "\n"); //println(script); }

ControlP5 Library Slider

$
0
0

Hii, i am using the ControlP5 library with Sliders, does anyone know how can i Only show the Current Value ? i mean i want to see the Values right near the Silder only when i move the slider, and not getting so many Values rewritten over themselves.

thanks guys


how replace the box by a text (InteractionBox)

$
0
0

import com.leapmotion.leap.*;

int width = 800; int height = 600; color canvasColor = 0x000000; float turns = radians(360); float xRotation = 0; float yRotation = 0; Controller leap = new Controller();

void setup() { frameRate(120); size(800, 600, P3D); background(canvasColor); }

void draw(){ Frame frame = leap.frame(); Hand hand = frame.hands().frontmost(); if( hand.isValid() ) { InteractionBox box = frame.interactionBox(); Vector controlPosition = hand.palmPosition(); Vector normalizedPosition = box.normalizePoint(controlPosition, false); xRotation = turns * normalizedPosition.getX(); yRotation = turns * (1 - normalizedPosition.getY()); } background(canvasColor); translate(width/2, height/2); rotateZ(xRotation); rotateX(yRotation);

box(200); }

now I make a interaction stuff with Leap motion. I don't know how to replace the InteractionBox by a text (or words, e.g. apple)

GButton doesn't fire events in eclipse (G4P)

$
0
0

Hi, i'm new to this forum as well as to processing.

When i try to run the G4P example "G4P_Sketchpad" in eclipse the "btnClear"-Button won't fire an event when clicked. The same code in the processing-IDE is working but when run from eclipse the button is not firing events to handleButtonEvents(GButton button, GEvent event).

any help is appreciated. here comes the code copied from eclipse:

regards

package myPackageName;

import processing.core.*;
import g4p_controls.*;

public class View extends PApplet {

    GPanel pnl;
    GSketchPad spad;
    GButton btnClear;
    PGraphics pg;

    public static void main(String[] args) {
        PApplet.main(View.class.getName());
    }

    public void settings() {
        size(1024, 768);
    }

    public void setup() {
        // Now create and clear graphic to be used (JAVA parameter
        // parameter is only needed for Processing 1.5.1)
        pg = createGraphics(640, 480);
        clearGraphic();
        // Create the G4P control to position and display the graphic
        spad = new GSketchPad(this, 0, 0, 350, 200);
        // Set the graphic for this control.
        // The graphic will be scaled to fit the control.
        spad.setGraphic(pg);
        // Create the button to clear the graphic
        btnClear = new GButton(this, 0, 0, 80, 20, "Clear");
        // Create the panel and add the controls
        pnl = new GPanel(this, 0, 0, 400, 300, "Sketch Test");
        pnl.addControl(btnClear, 10, 24);
        pnl.addControl(spad, 10, 50);
        // Expand the panel
        pnl.setCollapsed(false);
    }

    public void draw() {
        background(240);
        // Every 20th frame update the sketchpad graphic
        if (frameCount % 20 == 0)
            updateGraphic();
    }

    void handleButtonEvents(GButton button, GEvent event) {
        if(button == btnClear && event == GEvent.CLICKED) {
            clearGraphic();
        }
        // debug
        println(button);
        println(event);
    }

    // Clear the sketchpad graphic
    void clearGraphic() {
        pg.beginDraw();
        pg.background(255, 255, 200);
        pg.noFill();
        pg.ellipseMode(CORNERS);
        pg.endDraw();
    }

    // Add a line or ellipse to the sketchpad graphic
    void updateGraphic() {
        float x0 = random(10, pg.width - 10);
        float x1 = random(10, pg.width - 10);
        float y0 = random(10, pg.height - 10);
        float y1 = random(10, pg.height - 10);
        int col = color(random(64, 255), random(64, 255), random(64, 255));
        pg.beginDraw();
        pg.stroke(col);
        pg.strokeWeight(random(2, 5));
        if (random(0, 1) < 0.5f)
            pg.line(x0, y0, x1, y1);
        else
            pg.ellipse(x0, y0, x1, y1);
        pg.endDraw();
    }
}

HI, after exporting Sketch to .exe , all the stuff from G4P is not visible ???

$
0
0

after exporting the sketch and run the exe. All the stuff i made with the g4p is not visible in the main window. But the text and Images i wrote alone are showen. Have i had to add an extra lib or jar in the exe Folders. Or is something in the code uncorrect?

sry for my english Ron

Capturing movement in recorded video

$
0
0

Hi!

I would like to capture movement in a recorded (not captured) video. I tried to transform a code from Learning Processing site as to match it to the recorded video - but it doesnt work, I have some strange erros. The code is as follows:

import processing.video.*;
Movie kot;
PImage prevFrame;
float threshold = 50;

void setup() {
  size(2000, 2000);
  kot = new Movie(this, "breathing.mp4");
  kot.loop();

  prevFrame = createImage(kot.width, kot.height, RGB);
}

void movieEvent(Movie kot) {

  prevFrame.copy(kot, 0, 0, kot.width, kot.height, 0, 0, kot.width, kot.height); // Before we read the new frame, we always save the previous frame for comparison!
  prevFrame.updatePixels();  // Read image from the camera
  kot.read();
}

void draw() {

  loadPixels();
  kot.loadPixels();
  prevFrame.loadPixels();


  for (int x = 0; x < kot.width; x ++ ) {
    for (int y = 0; y < kot.height; y ++ ) {

      int loc = x + y*kot.width;            // Step 1, what is the 1D pixel location
      color current = kot.pixels[loc];      // Step 2, what is the current color
      color previous = prevFrame.pixels[loc]; // Step 3, what is the previous color

      // Step 4, compare colors (previous vs. current)
      float r1 = red(current);
      float g1 = green(current);
      float b1 = blue(current);
      float r2 = red(previous);
      float g2 = green(previous);
      float b2 = blue(previous);
      float diff = dist(r1, g1, b1, r2, g2, b2);

      // Step 5, How different are the colors?
      // If the color at that pixel has changed, then there is motion at that pixel.
      if (diff > threshold) {
        // If motion, display black
        pixels[loc] = color(0);
      } else {
        // If not, display white
        pixels[loc] = color(255);
      }
    }
  }
  updatePixels();
}

Marker not getting detected to display my digital box

$
0
0

hello everyone. i m new to processing. i need help with below code.

what i m trying is that when my camera starts running it should show box as soon as the marker is shown by me for detection. But it does not detect any marker or show any cube. But camera does start.

    import jp.nyatla.nyar4psg.*; // NyAR2 library from cpbotha.net for multi markers

    import processing.opengl.*;
    import processing.video.*;

    Capture vid;
    NyARMultiBoard nya;

    void setup(){
      size(640,480,P3D);

      vid= new Capture(this, 640,480, 30);
      String[] patts= {"patt.kanji"};
      double[] widths= {80};
      nya= new NyARMultiBoard(this, width, height, "camera_para.dat", patts, widths);

      vid.start();
    }


    void draw(){
      background(200);
      vid.read();
      image(vid,0,0);
           if(nya.detect(vid)) // marker detection code starts here
         {
          nya.markers[0].beginTransform();
          box(40);
          nya.markers[0].endTransform();

         }
    }

sound / FFT tutorial?

$
0
0

Hi, I'm new to processing so please excuse the newbie question. I'm trying to work with the FFT function of the sound library, and I've looked for tutorial information but all I've found is what looks like a book section describing the history of sound in the electronic arts (https://processing.org/tutorials/sound/). What I'd like is an actual tutorial that helps me to understand how to work with the FFT function specifically, and the sound library overall. If anyone could point me in the right direction it would be much appreciated - thanks!

How to call an instance of an object in a new class in an IDE?

$
0
0

I was wondering how I would be able to call an instance of a class from the main sketch in on of the classes i have created.

For example here how would I call the instance of WETriangleMesh "cave" in the new class meshpts. I have put notes where I am getting the error.

I have tried to run this in both IntelliJ and Eclipse but I can,t seem to figure it out.

Root Sketch

import processing.core.PApplet;
import peasy.*;
import toxi.geom.mesh.*;
import toxi.processing.ToxiclibsSupport;

public class MainApp extends PApplet {

    PeasyCam cam;
    ToxiclibsSupport gfx;
    WETriangleMesh cave;
    Meshpts pts;


    public static void main(String[] args){
        PApplet.main("MainApp", args);
    }

    public void settings(){
        size(1400, 800,P3D);
        smooth();
    }

    public void setup(){
        cam = new PeasyCam(this,750,750,0,2200);
        cave = (WETriangleMesh) new STLReader().loadBinary(sketchPath("data/"+"cave.stl"), STLReader.WEMESH);
        pts = new Meshpts(this);
        gfx=new ToxiclibsSupport(this);
    }

    public void draw(){
        background(0);


        stroke(255, 0, 0);
        noFill();

        cave.run();

        pushMatrix();
        fill(40, 120);
        noStroke();
        strokeWeight(1);
        stroke(10);
        lights();
        gfx.mesh(cave, false, 10);
        popMatrix();

    }
}

Class Meshpts

import processing.core.PApplet;


public class Meshpts{
    PApplet p;


    public Flock(PApplet p){
        this.p = p;
    }

    void run() {
        cave.computeCentroid(); // error is here
    }

}

how to find blob in processing 3X version ?

$
0
0

how to find blob size and width and number of blob in current version if processing ?

Blob[] blobs = opencv.blobs( 100, w*h/3, 20, true ); this code works only on processing version 1.5.1.

sketch link https://openprocessing.org/sketch/52766

how to cross-fade music

$
0
0

How would I go about cross-fading music in Processing? As in one piece of music slowly fades out as the next one fades in.

Can this be done (somewhat) easily in Processing's Sound library, Minim, or some other library? It sounds like something basic enough that someone must have tried implementing it at some point but I haven't been able to track down any discussion on it.

Been tinkering with Minim for the past 3 days, and failed to get Sound up and running (VM failed), and was starting to wonder if I'm missing a simple solution or if it's one of those deceptively difficult problems..

If anyone could point me in the right direction that would be great, thanks :)

G4P Events Have Stopped working in 4+ And Processing 3

$
0
0

I recently upgraded a project to Processing 3 (latest), and upgraded G4P to 4.1 (latest). Now all my event handlers that are added with calls to addEventHandler have stopped working. I tried adding the method handle_button_events, thinking it might be an api change, but this also didn't solve the problem. Any thoughts?

Java API wrapper/library

Mirroring Capture help

$
0
0

How do you flip/mirror a video? Below is my code, where I am trying to get the video to play a mirrored image on processing using "int loc = (cam.width - i - 1) + j*cam.width;" Where I translate the x-axis to flip, subtracting the x-location of the particular pixel (where brightness is above 253) from the width of the screen, but somehow it is not working. What is the issue here?

import processing.video.*; int cols, rows; Capture cam;

void setup() {

//displays it full screen size (displayWidth, displayHeight);

cols = width;
rows = height; //30 fps is default so bellow won't change anything cam = new Capture(this, width, height, 30);

// Start capturing the images from the camera cam.start();

frameRate(30); background(0); }

void draw() { if(cam.available()) { //reads fresh-est pixels from camera cam.read(); cam.loadPixels(); loadPixels(); // Loop through every pixel. ++i is equivalent to i = i + 1. //for (int i=0; i<cam.pixels.length; i++) {

// Begin loop for columns(using width)
for (int i = 0; i < cols;i++) {
  // Begin loop for rows(using length)
  for (int j = 0; j < rows;j++) {

    // Where are we, pixel-wise? (cam.width - i - 1) means x-coordinate of the pixel mirrored
    int loc = (cam.width - i - 1) + j*cam.width;  // Reversing x to mirror the image

    if (brightness(cam.pixels[loc]) > 253) {
      pixels[loc] = color(255);
    }

 float red = red(pixels[loc]);
 float green = green(pixels[loc]);
 float blue = blue(pixels[loc]);

 blue = blue - 5;
 if(blue < 0) blue = 0;

 red = red - 5;
 if(red < 0) red = 0;

 green = green - 5;
 if(green < 0) green = 0;

 pixels[loc] = color(red, green, blue);

}

}

updatePixels();

} }

Viewing all 2896 articles
Browse latest View live