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

Re : Please help to change the existing coding so that it visualises colour

$
0
0


must be
  • in your folder's sketch or
  • in a folder named data in your folder's sketch

not sure - one of them

Webcam record, save and replay?

$
0
0
As most of the questions starts: I'm a total processing-n00b and I'd like some help from you all plz.
I'm in a situation, doing a project, and I want to make an application that records from the webcam for about 15 seconds, then stops recording and saves the recording, then replays the recording in the application? Is it possible? Where do I begin if so?


I've read something about the MovieMaker library(??), but can't find any good tutorials or such. Tried to make something with this codes if it's any help:




/**
 * Saving Frames example
 * by Daniel Shiffman.  
 * 
 * This example demonstrates how to use saveFrame() to render
 * our an image sequence that you can assemble into a movie
 * using the MovieMaker tool.
 */

import processing.video.*;

Capture cam;

int begin; 
int duration;
int time;

// A boolean to track whether we are recording are not
boolean recording = false;

void setup() {
  size(640, 480);
  smooth();
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[0]);
    cam.start();     
  }

  begin = millis();
  time = duration = 20;  
}

void draw() {

    if (cam.available() == true) {
    cam.read();
  }
  image(cam, 0, 0);
  // The following does the same, and is faster when just drawing the image
  // without any additional resizing, transformations, or tint.
  //set(0, 0, cam);
  
  // If we are recording call saveFrame!
  // The number signs (#) indicate to Processing to 
  // number the files automatically
  if (recording) {
    saveFrame("output/frames####.png");
  }
   
  // Let's draw some stuff to tell us what is happening
  // It's important to note that none of this will show up in the
  // rendered files b/c it is drawn *after* saveFrame()
  textAlign(CENTER);
  fill(255);
  if (!recording) {
    text("Press R to start recording.", width/2, height-24);
  } 
  else {
    text("Press R to stop recording.", width/2, height-24);
  }
  
  // A red dot for when we are recording
  stroke(255);
  if (recording) fill(255, 0, 0);
  else noFill();
  ellipse(width/2, height-48, 16, 16);
  
    if (time > 0)  time = duration - (millis() - begin)/1000;
  text(time, 80, 80);
}

void keyPressed() {
  
  // If we press r, start or stop recording!
  if (key == 'r' || key == 'R') {
    recording = !recording;
    
      begin = millis();
    time = duration;
  }
}
 


So what I've got so far is a webcam recording, although it saves a lot of snapshots, and a timer..?

Re : Webcam record, save and replay?

$
0
0
I have deleted the duplicate topic you posted in Libraries and Tool Development

In future please do not post duplicate topics - it does not get you any more replies but simply spreads the ones you do get accrosss multiple forums.

Re : Creating a "choose and zoom image" program

Re : Shading PShape

$
0
0
To fix things for 2.0 follow these steps...

1. Change your vertex shader to this:
  1. uniform mat4 projmodelviewMatrix;
  2. attribute vec4 inVertex;
  3. varying vec2 surfacePos;

  4. void main() {
  5.   surfacePos = inVertex.xy;
  6.   gl_Position = projmodelviewMatrix * inVertex;
  7. }
2. Change your main sketch to this:
  1. // peasycam + 2.0 crashes my sketch so I had to remove it
  2. import toxi.geom.Vec3D;
  3.  
  4. PShader shader;
  5. PShape torus;
  6.  
  7. void setup() {
  8.   size(800, 600, P3D);
  9.   shader = loadShader("check.fs", "check.vs");
  10.   torus = createTorus( 40, 40, 40, 40, 40, 40);
  11. }
  12.  
  13. void draw() {
  14.   background(50);
  15.   translate(width/2, height/2);
  16.   rotateX(radians(90));
  17.   rotateZ(frameCount*0.01);
  18.   scale(2);
  19.   shader(shader);
  20.   shape(torus);
  21. }
3. In the Torus class uncomment:
  1. tor.noStroke();

Re : Creating a "choose and zoom image" program

$
0
0


I have no idea about video - I don't even have a cam....
I easily can simulate the image stuff with the mouse...

what is your exact problem?

Does the code work?

What does it, what can't it do?

Maybe you need to be more specific...

Re : Shading PShape

$
0
0
Depending on the version of processing-2.0 you will be out of luck using peasycam, however there is a fix for processing-2.0b7 version here https://github.com/jeffg2k/peasycam (except mousewheel doesn't work on linux). Which is far from negative as alternative mouse "right" drag can also be used for zoom.

Re : Creating a "choose and zoom image" program

$
0
0
Sorry.
If you could suggest me how to do that program with the mouse, i think I could insert that code into this.
The problem is that I don't know how to realize the "image stuff with the mouse" program :(

I think you know what the background subtraction code can do, right?
More specifically, the part inside the "void draw {.......}" of the program I wanted to realize, will going inside the part where I wrote  "//I want to put here the "choose image". And the values mouseX and mouseY, will became maxposX and maxposY, so instead of the mouse, the cursor will be the highest part of the body.

Thanks a lot



Re : Shading PShape

Re : Webcam record, save and replay?

$
0
0
MovieMaker as a library is deprecated in the 2.0b series.
Now, you have to save the frames as images, and to use the tool (or some external software like ffmpeg) to make a movie out of it.

Re : Creating a "choose and zoom image" program

$
0
0


like this

  1.   if (mouseX>100&&mouseX<100+100&&mouseY>10&&mouseY<10+100)
  2.   {
  3.     imgBig=img1a.get(0, 0, img1a.width, img1a.height);
  4.   }
  5.   else if (mouseX>300&&mouseX<300+100&&mouseY>10&&mouseY<10+100)
  6.   {
  7.     imgBig=img2a.get(0, 0, img1a.width, img1a.height);
  8.   }
  9.   else if (mouseX>500&&mouseX<500+100&&mouseY>10&&mouseY<10+100)
  10.   {
  11.     imgBig=img3a.get(0, 0, img1a.width, img1a.height);
  12.   }
  13.   //

OpenGL particle system

$
0
0
Hi,

I'm trying to make particle system with high performance (using OpenGL). But I can't find any working example. I only came across many different errors (even processing wiki don't work).

Does anybody have any working example ? Could you share with me ?


> black screen without anything
http://wiki.processing.org/w/1,000,000_points_in_OpenGL_using_Vertex_Arrays

>pgl.gl cannot be resolved or is not a field
http://wiki.processing.org/w/Vertex_Array

>package "com.sun.opengl" does not exist ...
https://forum.processing.org/topic/vbo-particle-system


Re : OpenGL particle system

$
0
0
check out PDE\File\Examples if you not have yet.

select Demos\Graphics\Particles

Re : OpenGL particle system

$
0
0
IMHO you can't mix in the same sentence high performance and processing for the time being at least ...

However you can find some high amount of particle examples on Open Processing :)

Cheers !

Re : Creating a "choose and zoom image" program

$
0
0
Thank you very much.
Sorry but I haven't understand how to write the program properly with your code, because I started used Processing only a month ago..
Which kind of var should I add to my code? And how\where can I tell to your code program the name of my images ( exampleimage = loadImage("exampleimage.jpg"); )?



P2D and set() behave strange

$
0
0
Hi,
this code works OK with default render ( fills up the screen from top to down ), however with P2D it makes strange things (makes some strips like a comb). I think it is because of some incompactibility of set() function with P2D render (I guess something like bad synchronization of framebuffer operations...).

I use processing 2.0b6  (maybe in 2.0b7 it is already repaired, I don't know)

  1. final int sz = 512;
  2. final int sz2 = sz*sz;
  3. final int n = 1000;

  4. int npoints;
  5. color c;

  6. void setup(){
  7.   //size(sz,sz    );   // this works OK
  8.   size(sz,sz,P2D);   // this behave strange
  9.   background(255);
  10.   color c = color(random(255), random(255), random(255));
  11. }

  12. void draw(){
  13.   for (int i=0;i<n; i++){    // loop over some chunk of workitems
  14.     int id=npoints%sz2;    // workitem id
  15.     if (id==0){ c=color(random(255), random(255), random(255));  }  // new screen start here
  16.     int ix=id%sz; int iy=id/sz;    // indexes of pixel
  17.     set( ix,iy, c  );
  18.     npoints++;
  19.   } 
  20. }
  21.  
NOTE - if you ask why the hell I tried such silly way of rastering over the whole screen, it is because I use processing to debug Kernels for OpenCL, and there varibale "id" is index of workitem 


Re : I need Help

$
0
0
Still can't decipher your explanation! 
I know many exotic things about Java,
but this one is still very alien for me! 

Re : While trying to merge an audio example with an open file dialogue -> I get GLExeption: cannot call invokeAndWait?

Re : P2D and set() behave strange

$
0
0
No, I ask why you use the P2D mode, since it doesn't work for you...
But of course, it is legitimate curiosity why it is problematic.
In 2.0b, P2D is OpenGL, so I suppose setting pixels repeatedly might not be perfect (OpenGL tends to shine in 3D but seems to have problems in 2D -- although I am far from being knowledgeable on the topic).

Re : I need Help

$
0
0
OK, let me illustrate it:
  1. void setup()
  2. {
  3.   println(getItems()[2]);
  4.   exit();
  5. }
  6.  
  7. int[] getItems()
  8. {
  9.   int[] items = { 0, 1, 2, 3, 4, 5 };
  10.   return items;
  11. }
getItems() returns an array, and we can pick one item from it directly.
The return value of a method can be used immediately.
This allows some nice tricks, like chaining calls:
  1. StringBuilder sb = new StringBuilder("Initial ");
  2. sb.append("one ").append("two ").append("Last");
because append() just returns this.
Viewing all 1768 articles
Browse latest View live