Quantcast
Channel: Processing Forum
Viewing all 1768 articles
Browse latest View live

Re : using timer

$
0
0
Without answering fully your request, as I haven't played much with the Movie library, here are some generic advices:
- Load help.png in setup(): if you load in the middle of a sketch, it will make a visible stop in the succession of frames, so when you don't need to load a bunch of images, just load them upfront.
- The condition you look for is:
if (millis() > time2)
if you want the event to happen after time2.
At a simple level, if you want to display the movie for the first period and the image after it, it would be something like:
  1. void draw() {
  2.   background(0);
  3.   if (millis() < time2) {
  4.     image(movie, 0, 0);
  5.   } else {
  6.     image(helpimg, 0, 0);
  7.   }
  8. }
If you want more complex conditions, you can start to use booleans or integers to reflect the state of your sketch.
For example, with integers, you can number steps:
1 = display movie
2 = display help
3 = display movie again, for a different duration
etc.
The switch keyword is useful for this kind of state management...

Re : video input with elements

$
0
0
Moved to Core Library section as it involves video.
It is good you show your working code, but perhaps you can show also a version of one of your attempt to add a special effect: it will show us what kind of stuff you want to do, and perhaps you are close of the solution with just a little blopper stopping it from working, which might be easy to fix. Or at least, it will give us some concrete direction to give advices.

Re : I am trying to create a sort of photoBooth In Processing

$
0
0
Since your question has nothing to do with video (although the presence of this library made me move it to this section), it is better to remove everything not related to video, ie. keep only the logic of your buttons, since these are what is problematic, to show to us.

Although I think I spotted the error in your code by reading it (but sometime, it is harder, and running the code can help).

Basically, there is an inefficiency with your code: whatever the conditions, you display the background. So, you can move all the calls to image(img) to the start of draw(), where it is called traditionally.
And it will probably solve your problem: because once you have drawn the first button, you hide it with the next call to image(img), actually!
Likewise, the multiple calls to the video between each button is redundant. Better move this to the end of draw().

Re : compare measurement of "x color" pixels compared to background

$
0
0
Great! Let me give this a look over and try to incorporate. Thanks a bunch!

Re : compare measurement of "x color" pixels compared to background

$
0
0
Works like a charm!  Thanks so much.

Re : How to log sensor arduino data into a file.

$
0
0
Yes i do have something in the console but nothing in the file :(.

Re : I am trying to create a sort of photoBooth In Processing

$
0
0
How about this, is this better?
The problem still stands because all buttons should display but they are not and also i tried some filters but they werent working properly so i took them out
Also can you help me with trying to put in camera filters where the videos should be?

PhotoBooth

Re : How to log sensor arduino data into a file.

$
0
0
Your code, once I removed the Serial stuff, works for me, so I don't know where your problem can be.

Re : I am trying to create a sort of photoBooth In Processing

$
0
0
I can't help you as I don't have a camera and don't do much video...
I have no time to download, unzip and look at a file right now. If the code isn't too long and don't need special files, it is better to show it here.

Re : I am trying to create a sort of photoBooth In Processing

$
0
0
ok well Hopefully you can help with the button problem and maybe try the video anyway here is the code

  1. import processing.video.*;//opens up processing libraries

    //class
    Capture video;//class for cideo

    Button[] button = new Button[4];//class will be called button


    PImage img;//class img

    boolean state; // keyPressed
    //===================================
    void setup() {
      size(1500, 1098);
      background(0);

      img = loadImage("Octoton Background Big.jpg"); //image file name
      frameRate(30);
      imageMode(CENTER);
      //Inititialize class
      for (int i = 0; i< button.length; i++) {
        button[i] = new Button(250+(i*75), 250);
      }

      button[0].setColor(0, 255, 0);//green
      button[1].setColor(0, 0, 255);//blue
      button[2].setColor(255, 255, 0);//yellow
      button[3].setColor(142, 56, 142);//purple

      video = new Capture (this, 640, 480, 30);//(video, width, height, frameRate)
      video.start();


      ellipseMode(CENTER);
    }
    //======================END SETUP===================



    void draw () {

      image(img, width/2, height/2);// background drawn 

      //Calls the Specific Button from the Void Button
      Button0();

      Button1();

      Button2();

      Button3();

      image(video, width/2, height/2+100);
    }



    //=============Button1=================

    void Button0() {

      if (keyPressed) {
        if (keyCode == UP) {

          button[0].display(true);
          state = true;
        }
      }
      else {

        button[0].display(false);//button deafault displayed
      }
      if (video.available()) {// if there is something to see it will be available
        video.read();// read what is available
      }
      tint(mouseX, mouseY, 255);
    }

    //=============Button2=================


    void Button1() {
      if (keyPressed) {
        if (keyCode == DOWN) {
         
          button[1].display(true);
          state = true;
        }
      }
      else {
       
        button[1].display(false);//button deafault displayed
      }
      if (video.available()) {// if there is something to see it will be available
        video.read();// read what is available
      }
    }
    //=============Button3=================

    void Button2() {
      if (keyPressed) {
        if (keyCode == LEFT) {
         
          button[2].display(true);
          state = true;
        }
      }
      else {
       
        button[2].display(false);//button deafault displayed
      }
      if (video.available()) {// if there is something to see it will be available
        video.read();// read what is available
      }
    }

    //=============Button4=================

    void Button3() {
      if (keyPressed) {
        if (keyCode == RIGHT) {
         
          button[3].display(true);
          state = true;
        }
      }
      else {
       
        button[3].display(false);//button deafault displayed
      }
      if (video.available()) {// if there is something to see it will be available
        video.read();// read what is available
      }
    }
    //=======================CLASS=================
    class Button {
      color col; // color variable
      int x;
      int y;

      Button(int tempX, int tempY) { // constructor
        x = tempX;
        y = tempY;
      }


      void display(boolean tempState) {


        fill(155);//gray

        ellipse(x, 258, 60, 30); // Base of button

        if (tempState == true) {
          Pressed();
        }
        else {
          notPressed();
        }
      }

      //=======================notPressed=================
      void notPressed () {
        //Button Default

        fill(col);//color set 

        ellipse(x, 254, 50, 20);
        ellipse(x, 253, 50, 20);
        ellipse(x, 252, 50, 20);
        ellipse(x, 251, 50, 20);
        ellipse(x, 250, 50, 20);
        ellipse(x, 249, 50, 20);

        ellipse(x, 248, 50, 20);
        ellipse(x, 247, 50, 20);
        ellipse(x, 246, 50, 20);
        ellipse(x, 245, 50, 20);
      }


      //=======================Pressed=================
      void Pressed() {
        // Button Pressed

          fill(col);//color set

        ellipse(x, 254, 50, 20);
        ellipse(x, 253, 50, 20);
        ellipse(x, 252, 50, 20);
        ellipse(x, 251, 50, 20);
        ellipse(x, 250, 50, 20);
      }

      //=======================setColor=================
      void setColor(int tempR, int tempG, int tempB) {
        col = color(tempR, tempG, tempB);
      }
    }

Re : How to log sensor arduino data into a file.

$
0
0
Could you post your code here,so i could retry it.

Re : How to log sensor arduino data into a file.

$
0
0
The code works, but it does only write data once and then closes the output-stream. So any data beeing recieved after that point wont be in your logfile. Try to close the output-stream on keypressed or exit maybe. Something like this:
  1. void exit() {
      output.close();
    }

Re : How to log sensor arduino data into a file.

$
0
0
Same problem,no data written in the file.

Re : I am trying to create a sort of photoBooth In Processing

$
0
0
Instead of having four times almost the same function, why don't you put it in the class?
You would need to specify which key is handled by which button.
And you still read the video four times per frame.

If I remove the image loading / displaying and the video reading / displaying, I can see your buttons.
Perhaps the video is hiding them.

Re : How to log sensor arduino data into a file.

$
0
0
As I wrote, it is just your code without the Serial stuff:
  1. PrintWriter output;

  2. void setup() {
  3.    output = createWriter( "newp.txt" );
  4. }

  5. void draw() {
  6.          String value = "Some stuff";
  7.          if ( value != null ) {
  8.               output.println( value );
  9.                output.close();
  10.          }
  11. }

How to use pgl.drawElement ?

$
0
0
Hello !

First of all, sorry if my english is not perfect, I'm from France and speak english approximately.

I'm new in Processing / OpenGL (I discovered it one month ago) but I'm good enough in ActionScript3 and have already done some projects based on GPU with FlashPlayer 11.

I'm trying to build a java library to "simulate" a Flash-project structure in Processing  (with different kinds of displayObject / DisplayObjectContainer , customEvents , ...). I actually know how to do it easily with pushMatrix and popMatrix but what I really want to do is calculate all these stuffs inside a VertexShader. 

My vertexShader works as expected with a single plane using pgl.drawArrays , but because I have no access to the 'IndexBuffer' (-> the buffer that registers the indices) with pgl.drawArray , I can't figure out how I can draw more than one "shape" in the same 'drawArrays' call.

I mean... If I undestand well (but maybe I don't) how works pgl.drawArrays , all the triangles must be interconnected , but I want to draw thousands of 'single plane' in the same 'draw call'. 

I look around in the source code of PGL.java and found pgl.drawElements and I think that's what I want :)
But, obviously, there is a problem : drawElements needs 4 int arguments and no int[]. I guess it works like pgl.getAttribLocation but I don't find the good method... I searched a lot, found some stuff for processing 1.5 but nothing for processing 2...

Can someone help me ?


Thanks !



Re : How to use pgl.drawElement ?

$
0
0
Maybe I'm not in a good direction...

In a perfect world, I would like to have a code similar to the "TextureQuad exemple" (in example/topic/texture) but with additional custom attributes that affect the vertexShader. 

Is it possible to do it without using a "low level structure"?


Thanks !

pre-sales questions regarding Rochen’s range

$
0
0

Trying to trigger video Filters with a touch of several buttons Need Urgent Help

$
0
0
Hi,  I am a new programming student and for my school final I am trying to create a sort of Photo Booth using the camera on a mac or any kind of computer camera with different filters that are triggered with arrow keys like tints and distortions basically some of the things that are in Mac's Photo Booth. I tried some methods but was unsuccessful so i took it out of the program.


Here are the Files for everything in my program
Photo Booth

  1. import processing.video.*;//opens up processing libraries

    int currentKey;   //integer variable save coded key numeric rep of ASCII

    int s;// saved time

    int t = 5000;// 5 seconds

    //class
    Capture video;//class for cideo

    Button[] button = new Button[4];//class will be called button


    PImage img;//class img

    boolean state; // keyPressed
    //===================================
    void setup() {
      size(1500, 1098);
      background(0);

      img = loadImage("Octoton Background Big.jpg"); //image file name
      frameRate(30);
      imageMode(CENTER);
      //Inititialize class
      for (int i = 0; i< button.length; i++) {
        button[i] = new Button(250+(i*75), 250);
      }

      button[0].setColor(0, 255, 0);//green
      button[1].setColor(0, 0, 255);//blue
      button[2].setColor(255, 255, 0);//yellow
      button[3].setColor(142, 56, 142);//purple

      video = new Capture (this, 640, 480, 30);//(video, width, height, frameRate)
      video.start();

      s = millis(); //sets s to millis
      ellipseMode(CENTER);

      currentKey = 0;
    }
    //======================END SETUP===================



    void draw () {
     
      image(img, width/2, height/2);// background drawn 

      dispVid();  //draw video to screen

      Button1();

      Button2();

      Button3();

      Button4();
     
    }

    //function to check if a key has been pressed
    void keyPressed() {

      currentKey = keyCode;  //assign the keycode representation of the ASCII character to currentKey
      println(currentKey);  //print the value
    }

    //=============Button1=================

    void Button1() {
      if (currentKey == 38) {  //the keycode for ASCII UP button on the keyboard is 38. Eval if currentKey is 38
        button[0].display(true);
        println("Button 1 Pressed");
      }
      else {   //if the keycode is not UP aka 38 set the display method to false for the default
        button[0].display(false);//button deafault displayed
        println("Button 1 Not Pressed");
      }
    }

    //=============Button2=================

    void Button2() {
      if (currentKey == 40) { //the keycode for ASCII UP button on the keyboard is 40. Eval if currentKey is 40
        button[1].display(true);
        println("Button 2 Pressed");
      }
      else { //if the keycode is not UP aka 40 set the display method to false for the default
        button[1].display(false);//button deafault displayed
        println("Button 2 Not Pressed");
      }
    }

    //=============Button3=================

     void Button3() {
      if (currentKey == 37) {  //the keycode for ASCII UP button on the keyboard is 38. Eval if currentKey is 38
        button[2].display(true);
        println("Button 3 Pressed");
      }
      else {   //if the keycode is not UP aka 38 set the display method to false for the default
        button[2].display(false);//button deafault displayed
        println("Button 3 Not Pressed");
      }
    }

    //=============Button4=================

    void Button4() {
      if (currentKey == 39) { //the keycode for ASCII UP button on the keyboard is 40. Eval if currentKey is 40
        button[3].display(true);
        println("Button 4 Pressed");
      }
      else { //if the keycode is not UP aka 40 set the display method to false for the default
        button[3].display(false);//button deafault displayed
        println("Button 4 Not Pressed");
      }
    }
     //to draw current frame of video to the screen
    void dispVid() {

      if (video.available()) {// if there is something to see it will be available
        video.read();// read what is available
      }   
      image(video, width/2, height/2+100);
    }

    //=======================CLASS=================
    class Button {
      color col; // color variable
      int x;
      int y;

      Button(int tempX, int tempY) { // constructor
        x = tempX;
        y = tempY;
      }


      void display(boolean tempState) {


        fill(155);//gray

        ellipse(x, 258, 60, 30); // Base of button

        if (tempState == true) {
          Pressed();
        }
        else {
          notPressed();
        }
      }

      //=======================notPressed=================
      void notPressed () {
        //Button Default

        fill(col);//color set 

        ellipse(x, 254, 50, 20);
        ellipse(x, 253, 50, 20);
        ellipse(x, 252, 50, 20);
        ellipse(x, 251, 50, 20);
        ellipse(x, 250, 50, 20);
        ellipse(x, 249, 50, 20);

        ellipse(x, 248, 50, 20);
        ellipse(x, 247, 50, 20);
        ellipse(x, 246, 50, 20);
        ellipse(x, 245, 50, 20);
      }


      //=======================Pressed=================
      void Pressed() {
        // Button Pressed

          fill(col);//color set

        ellipse(x, 254, 50, 20);
        ellipse(x, 253, 50, 20);
        ellipse(x, 252, 50, 20);
        ellipse(x, 251, 50, 20);
        ellipse(x, 250, 50, 20);
      }

      //=======================setColor=================
      void setColor(int tempR, int tempG, int tempB) {
        col = color(tempR, tempG, tempB);
      }
    }

Processing core video:217): GStreamer-CRITICAL **

$
0
0
Never encountered this one before. After resolving my applications issues in this thread I decided to move the application bundle over to an installation computer hooked up to a large display in the hallway of my work. I had to swap out the video library native libs for the 32 bit ones, and then change the camera device being selected, and then I got this string of really strange errors:

** (Processing core video:217): WARNING **: ColorConverter: size 62400 is not a multiple of unit size 60000
2012-12-04 12:41:11.523 JavaApplicationStub[217:903] invalid drawable

(Processing core video:217): GStreamer-CRITICAL **: 
Trying to dispose element nat, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.


(Processing core video:217): GStreamer-CRITICAL **: 
Trying to dispose element Video Capture, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element. 

I can't seem to find anything existing in the forum about this. I am running it on a Mac Mini 1.66ghz Intel Core Duo with 1gb of ram running OS X 10.6.8 and the Processing 2.0b6 core and video libraries.

Viewing all 1768 articles
Browse latest View live