Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

  • Not working emulator

    Here what I get from Android Virtual Device Manager in Android Studio:

    Name: processing_phone

    CPU/ABI: ARM (armeabi-v7a)

    Path: C:\Users\HP\Documents\Processing\android\avd\processing-phone

    Target: default [Default] (API level 24)

    Skin: 480x800

    SD Card: 64M

    hw.dPad: no

    hw.lcd.height: 800

    hw.accelerometer: yes

    hw.device.name: Nexus One

    hw.device.manufacturer: Google

    hw.lcd.width: 480

    hw.gps: yes

    image.androidVersion.api: 24

    hw.audioInput: yes

    image.sysdir.1: system-images\android-24\default\armeabi-v7a\

    hw.cpu.model: cortex-a8

    tag.id: default

    hw.mainKeys: yes

    hw.lcd.density: 240

    hw.device.hash2: MD5:0250c2773d1dd25bb2b12d9502c789f7

    hw.trackBall: yes

    PlayStore.enabled: false

    hw.battery: yes

    hw.sdCard: yes

    tag.display: Default

    hw.sensors.proximity: yes

    hw.sensors.orientation: no

    avd.ini.encoding: UTF-8

  • Interaction with video projection

    as he getting closer

    For the sketch to know this you will probably need either:

    1. a proximity sensor or
    2. a depth-sensing camera (e.g. a Kinect) or
    3. computer vision tracking (e.g. OpenCV / BoofCV) that guesses at depth using e.g. markers.
  • How can I scan a plant of a room with Arduino and draw it in Processing?

    Is there a goal, or is the goal just to move without bumping into anything?

    Is there a rule about what kind of sensor(s) you can use? Any distance sensor, proximity sensor, or camera? Or have you already chosen one, e.g. a laser sensor, ultrasonic sensor, or camera.

  • How would I add another target on the path for the enemies to go to after they reach the first one?

    Some principles to consider:

    1. The number of targets shouldn't matter to your design. You should be able to have a list of 2 targets or 200, and be able to change them by changing just the target definitions as e.g. a global variable.

    2. The enemies don't need to know the whole target list -- they just need to know a single target, and how to get / be given a new one once the old one is reached (or destroyed, depending on game genre).

    3. If the wave is in charge of the target, every enemy gets a new target no matter where they are. If the wave holds a target list, enemies can check that list each time they reach a target.

    4. Built-in classes like PVector have built-in methods for moving from one location towards another.

    5. Has the enemy arrived? check with proximity (<) not equality (==).

    6. What should happen at the final target?

  • Help to optimise proximity particles

    You only need to check the particles after the current particle for proximity. If a is close to b then b is close to a and you've already joined them together with a line anyway.

    I'd also square both sides of your distance method, get rid of the expensive sqrt.

  • Help to optimise proximity particles

    Hi, I'm trying to draw lines between particles if they are close enough to each other. My code seems to do that however the frame rate drops to pretty much 0.

    How can I make this faster? Code here: https://codepen.io/jmean/pen/pdwXgO

    Thanks

  • Make movie play using proximity sensors

    hi, I am working on a project that requires playing 3 videos when the person reaches 3 different distances. I am using processing 2.2.1 and arduino, just beginning. What must i take into consideration or what references can i look at?

  • how to use sensor(arduino) to control some images in Processing

    These next posts can be useful for you:

    https://forum.processing.org/two/discussion/comment/85556/#Comment_85556

    https://forum.processing.org/two/discussion/comment/88886#Comment_88886 (check Feb 27)

    https://forum.processing.org/two/discussion/comment/88115/#Comment_88115

    Previous posts that might be relevant:

    https://forum.processing.org/two/search?Search=proximity

    Now, I have to say it is not clear what you want to do. Here:

    These sensors will be located in the 4 corners of one image

    Do you mean that the sensors are located in four different corners in a room and they will affect each corner in your sketch? Can you clarify this as it is a very important detail.

    I guess that the problem probably is the communication between Arduino and processing.

    I will strongly suggest to work on a simple demo where you work with your ardunio and one sensor + processing. The concept here is for you to become comfortable working with processing, to make sure your arduino+processing communication is working and that you understand your sensor. This program is also very important so you can test any of your sensors to make sure each of them works and that they all behave similarly as dictated by specs. For example, if you are either 20 or 50 cm in front of the sensor, do all sensors output the same value?

    What code do you have so far?

    Kf

  • how to use sensor(arduino) to control some images in Processing

    Hi all, I am curently working for one installation with Arduino and Processing. In general, there will be 4 sensors to detecting the movement of ppl in this project. These sensors will be located in the 4 corners of one image. Once one sensor detect someone's movement, we will immediately see that one image transforme into another one. The others sensors work in the same way. And the image will be changed all the time once one sensor catch one movement.

    The main problem for me is writing the programe with Processing. (I hope that the animation like some circles turn to a pack of molecule.) But the transformation must be happened when the sensor catch something. I guess that the problem probably is the communication between Arduino and processing.

    I am totally a beginner of the language java. I have already tried to find some online tutorials, but i can't find any one because the most of transformations happened with our mouse.

    So i am here for looking for help. Anyone knows how to transform one image into another accroding to the movement of ppl specially with arduino? Or anyone can give me some advices ou idee?

    Thanks a lot !!!

    PS : i use infrared proximity sensor (Sharp GP2Y0A02YK0F)G

  • [PAID] Help to debug patch

    if i leave the problem point in and comment out the other point then that also works. so it might be the proximity.

  • how to invert input from sensor?

    hello, beautiful people.

    I'm working with an ultrasonic proximity sensor from which I get values that range from 0 to 200, and are directly proportional to the distance the object measured by the sensor is from it, in centimeters. if an object touches the sensor, the value measured is 0.

    I would like to invert this connection: instead of a directly proportional input, an inversely proportional one, from which I get bigger values the closer the object is to the sensor. how could I achieve this?

  • Find longest string of overlapping circles

    Hi everyone, total P5.js newbie here so be gentle!

    I've written a basic script (with some serious help from TheCodingTrain's youtube videos) to draw x number of circles from an array, distributed randomly in the canvas. Whenever two circles overlap they turn red.

    Does anyone know how I could modify this script so that only the longest string of continuously overlapping circles is highlighted? There are always multiple discreet groups of overlapping circles which don't interact with each other. I'm trying to simulate the spread of a proximity based worm for my dissertation, so I don't need to see if there are two overlapping circles which don't link to any other circles in the array etc.

    I hope that's kind of a clear explanation of what I'd like to achieve.

    The script can be found at the dropbox link below.

    https://www.dropbox.com/sh/6njxm1qik2nbcqo/AAB5M42mdMpufvjzl43iYmJCa?dl=0

    Thanks

  • multi page PDF. / getting blank page every 5 pages

    Wrote this little program that takes a master image (local), splits it into pages (because it's big), and reproduces it with tiles (taken from Flikr) based on averaged colors. On the back of each sheet is a page number, so we know ho to put them back order. All works great! very pleased! But for some reason, i get a blank page every 5 pages... why? Master image size is currently 4771 x 3181px

    Also, this code probably needs some optimization, but that's another topic.

    /**
     * This code is copyright (c) Mathias Markl 2016 (the imageLoader part)
     *
     * This program is free software: you can redistribute it and/or modify it under
     * the terms of the GNU General Public License as published by the Free Software
     * Foundation, either version 2 of the License, or (at your option) any later
     * version.
     * 
     * This program is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
     * details.
     * 
     * You should have received a copy of the GNU General Public License along with
     * this program. If not, see <http://www.gnu.org/licenses/>.
     */
    
    import at.mukprojects.imageloader.*;
    import at.mukprojects.imageloader.flickr.*;
    import at.mukprojects.imageloader.image.*;
    
    import processing.pdf.*;
    
    
    PGraphicsPDF pdf;
    
    
    ImageLoader loader;
    ImageList list;
    Image img;
    
    String apiKey = "xxxx";
    String apiSecret = "xxxx";
    
    PImage master = new PImage();
    PImage cover = new PImage();
    
    int maxImages = 50;
    int detail = 50;
    int loaderOn = 1;
    int extra;
    
    PImage[] myImages = new PImage[50];
    
    StringList imageSorter = new StringList(0);
    int c=0;
    int i=0;
    int j =0;
    int k =0;
    int n =0;
    int o=0;
    
    //// Image Thingies
    
    PImage baseImage;
    int baseIndex=5;
    int maxHeight=900;
    int maxWidth=900;
    
    int rounderY;
    int rounderX;
    
    IntList rTile = new IntList(0);
    IntList gTile = new IntList(0);
    IntList bTile = new IntList(0);
    int rBase;
    int gBase;
    int bBase;
    IntList cRVar = new IntList(0);
    IntList cGVar = new IntList(0);
    IntList cBVar = new IntList(0);
    IntList cVar = new IntList(0);
    IntList targetArray = new IntList(0);
    
    int target;
    int page=1;
    PFont noPage;
    
    void setup() {
      size(1000, 1000);
    
      loader = new FlickrLoader(this, apiKey, apiSecret);
      list = loader.start("sunset", false, 60*1000);
    
      master=loadImage("master.jpg");
    
      pdf = (PGraphicsPDF)beginRecord(PDF, "Lines.pdf");
    
      frameRate (60);
    }
    
    void draw() {
    
    
      if (loaderOn==1) {
        println("retrieved "+list.size()+" photos");
        //println(list.getIds());
    
    
        // Remove Duplicates
    
        if (list.size()==maxImages) {
          for (int b=0; b<maxImages; b++) {
            if (imageSorter.size()==0) {
              img = list.getImage(k);
              imageSorter.append(img.getImgUrl());
              k++;
            } else if (imageSorter.size()>0) {
              img = list.getImage(k);
              if (imageSorter.get(imageSorter.size()-1)==img.getImgUrl()) {
                k++;
              } else {
                imageSorter.append(img.getImgUrl());
                k++;
              }
            }
          }
    
    
          // Resizing all the funzies!
    
          println("LOADING IMAGES INTO PIMAGE ARRAY AND RESIZING");
    
          for (int i=0; i<imageSorter.size(); i++) {
            myImages[i]=loadImage(imageSorter.get(i), "jpg");
            myImages[i].resize(detail, detail);
          }
    
    
          // Tile Pixel Averaging Baby Boy
    
          println("LOADING AND AVERAGING TILE PIXEL COLORS");
    
          for (int i=0; i<imageSorter.size(); i++) {
            myImages[i].loadPixels();
            color r = 0, g = 0, b = 0;
    
            for (color c : myImages[i].pixels) {
              r += c >> 020 & 0xFF;
              g += c >> 010 & 0xFF;
              b += c        & 0xFF;
            }
    
            r /= myImages[i].pixels.length;
            g /= myImages[i].pixels.length;
            b /= myImages[i].pixels.length;
    
            rTile.append(r);
            gTile.append(g);
            bTile.append(b);
          }
          println("DONE");
          loader.stop();
          list=null;
          loaderOn=0;
        }
      }
    
    
    
      // Fonctions répetées à chaques page //
    
    
      if (loaderOn==0) {
    
        // Découpage du master en pages (imageBase)
    
        for (int v=0; v<master.height; v+=height) {
          for (int w=0; w<master.width; w+=width) {
    
    
            baseImage=master.get(v, w, width, height);
    
    
            // Découpage de la page en détails
    
    
    
    
            for (i=0; i<baseImage.width; i+=detail) {
              for (j=0; j<baseImage.height; j+=detail) {
    
                println("LOADING AND AVERAGING DETAIL COLORS"+" "+"DETAIL NO"+" "+(i+j));
    
                PImage newImg = baseImage.get(i, j, detail, detail);
    
                // Analyze de la couleur de chaque détail
    
    
                newImg.loadPixels();
    
                color rBase = 0, gBase = 0, bBase = 0;
    
                for (color c : newImg.pixels) {
                  rBase += c >> 020 & 0xFF;
                  gBase += c >> 010 & 0xFF;
                  bBase += c        & 0xFF;
                }
    
                rBase /= newImg.pixels.length;
                gBase /= newImg.pixels.length;
                bBase /= newImg.pixels.length;
    
                if ((rBase+gBase+bBase)==0) {
                  fill(255);
                  noStroke();
                  rect(i, j, detail, detail);
                } else {
    
                  // Calcule de détail le plus près de l'image de base
    
                  println("ANALYSING TILE COLOR PROXIMITY");
    
    
                  for (k=0; k<maxImages; k++) {
                    cRVar.append(abs(rBase-rTile.get(k)));
    
                    cGVar.append(abs(gBase-gTile.get(k)));
    
                    cBVar.append(abs(bBase-bTile.get(k)));
    
                    cVar.append(cRVar.get(k)+cGVar.get(k)+cBVar.get(k));
    
                    println("APPROX TILE NO"+k );
                  }
    
                  target = cVar.index(cVar.min());
                  println("MATHCHING TILE="+target);
                  image(myImages[target], i, j);   
                  println("CLEARING ALL VARIABLES");
    
                  c=o;
    
                  k=0;
                  n=o;
                  o=0;
    
                  cRVar.clear();
                  cGVar.clear();
                  cBVar.clear();
                  cVar.clear();
    
                  println("PRINTING TILE "+(i+j));
                }
              }
            }
            i=0;
            j=0;
            //baseImage.resize(0, 250);
            //image(baseImage, width-baseImage.width, height-baseImage.height);
    
            pdf.nextPage();
    
            PFont noPage = createFont("Helvetica", 100, true);
            textFont(noPage, 500);
            fill(225);
            textAlign(CENTER, CENTER);
            text(page, width/2, height/2);
    
            pdf.nextPage();
            page++;
          }
        }
        cover=master;
    
        if (cover.width>cover.height) {
          cover.resize(width-200, 0);
          rounderY = (cover.height%20);
          cover.resize(width-200, cover.height-rounderY);
        } else if (cover.width<cover.height) {
          cover.resize(0, height-200);
          rounderX = (cover.width%20);
          cover.resize(cover.width-rounderX, height-200);
        }
        PFont noPage = createFont("Helvetica", 100, true);
        textAlign(CENTER, CENTER);
        textFont(noPage, 20);
        text("Mosaïc Poster Maker", width/2, ((height-cover.height)/2)-100);
        text("Jonathan Mélançon", width/2, ((height+cover.height)/2)+100);
        imageMode(CENTER);
        image(cover, width/2, height/2);
    
        endRecord();
        println("PDF DONE!");
        exit();
      }
    }
    
  • change color by proximity ..

    How I change col/opacity/variable as it comes closer to center/fixed-point ? ex :- (ignore syntax) translate(width/2, height/2); fill(255,x) ellipse(mouseX,mouseY, 20,20);

    I want the opacity to be full as the ellipse comes close to the center(0,0);

    how do i calculate x ?

  • Constantly Changing an Objects Colour and Array Help!

    Hi. I am making a project on which I need my monster to have different behaviors in an array. The behaviors can consist of (jump(), move(), grow(), shrink() change_color(), etc...). These behaviours should be in the array and randomly called. My problems so far is that I was my creature to change colour whenever the change colour function is randomly called. Also how would I make the array to randomly call out the behaviors in the array? If this doesnt make sense here is my assignment for clarification.

    "Your task is to create a class that represents a monster/character of your choice. Your character must be able to be drawn at any location on the screen, and should have some behaviours (possibilities: jump(), move(), grow(), shrink() change_color(), etc...).

    Make sure the following base features are all included:

    Your monster is defined in a class that has class variables, at least one constructor, and class functions. Use an array or ArrayList to store multiple instances of your class. There should always be more than one object active in the sketch (of course, there could also be hundreds). The monsters should move and choose actions (behaviors) autonomously. That is, once the program is running, what they are doing each frame of the animation is chosen by the program, not by the user. Have your creatures react to the mouse (either proximity to mouse cursor, or being clicked). Hint: You may want to explore the dist() function."

    And here is my code so far.

    void setup(){
      size(500,500);
      background(200,12,255);
      ellipseMode(CENTER);
    
    }
    void draw(){
      monster();
    
    }
    
    void changeColour(){
    
     for (int i = 10; i < 60; i = i++) {
      fill(255,255,255);
      monster();
    
    
    }
    
    }
    
    void monster(){
    
    //Head
    ellipse(150,50,50,85);
    ellipse(100,50,25,42);
    ellipse(200,50,25,42);
    ellipse(90,50,12,24);
    ellipse(209,50,12,24);
    ellipse(150,50,15,30);
    ellipse(150,50,4,4); 
    ellipse(85,50,2,3);
    ellipse(214,50,2,3);
    
    //fingers/hands
    ellipse(250,76,8,8);
    ellipse(260,82,8,8);
    ellipse(253,92,8,8);
    ellipse(50,76,8,8);
    ellipse(40,82,8,8);
    ellipse(47,92,8,8);
    
    //feet.
    ellipse(110,200,45,20);
    ellipse(190,200,45,20);
    ellipse(110,200,30,10);
    ellipse(190,200,30,10);
    
    //arms and legs
    triangle(100,130,110,200,150,150);
    triangle(200,130,190,200,150,150);
    triangle(100,71,50,85,100,130);
    triangle(200,71,250,85,200,130);
    
    
    rectMode(CENTER);
    
    //eyes
    rect(125,100,30,10);
    rect(175,100,30,10);
    rect(125,100,5,5);
    rect(175,100,5,5);
    
    //additional eyes lines
    line(100,71,150,93);
    line(200,71,150,93);
    line(100,29,126,40);
    line(200,29,174,40);
    
    
    // mouth
    line(125,120,175,120);
    
      //pupils
    rect(125,100, 5, 5);
    rect(175,100, 5, 5);
    
    
    
    }
    

    Thank you for you help, anything helps! I am not expecting the answer, I am just hoping to be pointed in the right direction!

  • Creature Creation

    Hello,

    I am having trouble with my code that I am working on in Processing using Java.

    I am trying to create a class with a creature that has behaviors like jump(), move(), grow(), shrink() change_color(), etc...).

    1.The creature is defined in a class that has class variables, at least one constructor, and class functions.

    2.Use an array or ArrayList to store multiple instances of your class. There should always be more than one object active in the sketch (of course, there could also be hundreds).

    3.The creature should move and choose actions (behaviors) autonomously. That is, once the program is running, what they are doing each frame of the animation is chosen by the program, not by the user.

    4.Have your creatures react to the mouse (either proximity to mouse cursor, or being clicked). Hint: You may want to explore the dist() function.

    Anything help, thanks!

  • EGLDisplayUtil error – Processing on Raspberry

    Hello everyone,

    I'm working on a raspberry and when I run it, I everytime have this error in the console: (but the sketch run even though)

    EGLDisplayUtil.EGLDisplays: Shutdown (open: 1)
    EGLDisplayUtil: Open EGL Display Connections: 1
    EGLDisplayUtil: Open[0]: 0x1: EGLDisplayRef[0x1: refCnt 2]
    

    Do you know what does it mean and how I can solve it? The sketch read the values of the arduino (plugged on the raspberry) where a proximity sensor is plugged and when we put an object above the sensor the first video change and another one is launched. I also have another problem: When the sketch is running, the videos are slow down. And I remove everything that relate to the arduino and the sensor in processing, the videos are fine.

    So is somebody can help me for this, it drives me crazy, and I didn't found a thing on our friend Google... Thanks so much :)

    Here my code:

        ////////////////////////////////////////////
        ////////////////////////////////// LIBRARIES
        ////////////////////////////////////////////
    
        import processing.serial.*;
        import processing.video.*;
    
    
    
    
    
        /////////////////////////////////////////////////
        ////////////////////////////////// INITIALIZATION
        /////////////////////////////////////////////////
    
        Movie mymovie;
        Movie mymovie2;
    
    
    
    
    
        ////////////////////////////////////////////
        ////////////////////////////////// VARIABLES
        ////////////////////////////////////////////
    
        int lf = 10;    // Linefeed in ASCII
        String myString = null;
        Serial myPort;  // The serial port
        int sensorValue = 0; //value of the sensore
        int x = 100; //the sensor will be triggered when this value is reached. Modify it to change when the videos will switch
    
    
    
    
        /////////////////////////////////////////////
        ////////////////////////////////// VOID SETUP
        /////////////////////////////////////////////
    
        void setup() {
          //frameRate(50);
          fullScreen();
          //size(1280, 1024, P3D);
          // List all the available serial ports
          printArray(Serial.list());
          // Open the port you are using at the rate you want:
          myPort = new Serial(this, Serial.list()[1], 9600);
          myPort.clear();
          // Throw out the first reading, in case we started reading 
          // in the middle of a string from the sender.
          myString = myPort.readStringUntil(lf);
          myString = null;
          //load the video
          mymovie = new Movie(this, "VIDEO_1_v06bis.mov"); //Modify the line in quotation marks to change the videos. (put it inside the "data" folder
          mymovie2 = new Movie(this, "VIDEO_2_v02.mov");
          //set the videos for a continuous loop
          mymovie.loop();
          mymovie2.loop();
        }
    
    
    
    
        ////////////////////////////////////////////
        ////////////////////////////////// VOID DRAW
        ////////////////////////////////////////////
    
        void draw() {
          //image(mymovie, 0, 0); //display the video in a continuous loop
          // to trigger the sensor
          // check if there is something new on the serial port
          while (myPort.available() > 0) {
            // store the data in myString 
            myString = myPort.readStringUntil(lf);
            // check if we really have something
            if (myString != null) {
              myString = myString.trim(); // let's remove whitespace characters
              // if we have at least one character...
              if (myString.length() > 0) {
                println(myString); // print out the data we just received
                // if we received a number (e.g. 123) store it in sensorValue, we sill use this to change the background color. 
                try {
                  sensorValue = Integer.parseInt(myString);
                } 
                catch(Exception e) {
                }
              }
            }
          }
    
    
          ///////////SENSOR TRIGGERED
          ///////////////////////////
    
          if (x < sensorValue) {
            mymovie.jump(0);
            //background(mymovie2);
            image(mymovie2, mouseX, mouseY);
            //mymovie2.pause();
          } else {
            //mymovie2.play();
            //mymovie.jump(0);
          }
    
    
          ///////////SENSOR NOT TRIGGERED
          ///////////////////////////////
    
          if (x > sensorValue) {
            mymovie2.jump(0);
            //background(mymovie);
            image(mymovie, mouseX, mouseY);
            //mymovie.pause();
          } else {
            //mymovie.play();
          }
        }
    
    
    
        //////////////////////////////////////////////
        ////////////////////////////////// VOID CUSTOM
        //////////////////////////////////////////////
    
        void movieEvent(Movie mymovie) {
          mymovie.read(); //read the video
          mymovie2.read();
        }
    
  • Performance optimization for p5.js sketch?

    Thanks for the suggestions.

    I have implemented a dist squared function which did help the performance a bit. Appreciate it.

    The reason why I am iterating through the entire list is each individual point has to know the distance between it and every particle to figure out who is the closest. This gives rises to a algorithm solution of O(dn^2). I am trying to find a better algorithm for the above kinetic visualization.

    I looked through the online sketch as well. However I don't believe it fits my case as the bouncing ball sketch does no account for distance between balls. Rather, it simply draws a line to the origin of any ball that fits its criteria, whereas the concept I am trying has to take into account the relative proximity between both particle.

    Cheers.

  • Sharp IR proximity sensor + arduino + Raspberry PI = Help

    Finally found the solution, if it can help somebody, here the link to github to see the code to trigger the webcam with a proximity sensor (Arduino + Processing).

    int x = 200 is the value of the proximity sensor that will trigger the webcam when it reach.

    https://github.com/lxnr-p/trigger-webcam-processing

    Cheers !