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

Re : Need some help with left to right/experiments with slitscan (Beginner's frustration)

$
0
0
thank you I think I am starting to slightly get my head around this!

I would like to double if i am correct about this section?

 //y is set at 0 and if that value is lower than video height then add the value
  for (int y = 0; y < video.height; y++){
// this sets the boundary for the loop to take place? which means the width of the canvas (but not sure how + drawPositionX adds to that because it is set to 0
      int setPixelIndex = y*width + drawPositionX; 
//this takes the video width and adds the section of video to that?
      int getPixelIndex = y*video.width  + videoSliceX;
      pixels[setPixelIndex] = video.pixels[getPixelIndex];
    }

PApplet's PGraphics instance

$
0
0
PApplet's PGraphics instance, g, is not documented in the API.

Is there a reason it is not listed in the API?  Is there a better way to access PApplet's PGraphics?

Because it is not documented, it is not being supported in processing.js.  This leads to complications in developing code to run on both platforms. 

Is PVector.equals implemented properly?

$
0
0
Hey, I want to have a set of unique vertexes for something, and I was planning on just using some flavour of Set in the standard library. It says that it checks object.equals(otherObject) to check if an item should be added or not. I was wondering if I'll have to extend the PVector class to make this work, or if it's a default feature already.

Minim Input Help

$
0
0
Hey :),

I am basically building a small program that manipulates sound using the Minim library (shows spectrum and allows filters), and i want to basically get the output that is coming from the speakers and input it into my program so it can be manipulated.

I am just not sure how to get the speaker output and turn it into an input :/

Any help would be appreciated :D

Thanks,

MetalCactuar

Re : PApplet's PGraphics instance

$
0
0
It is not documented in the reference, but being a public variable, it is documented in the JavaDoc...

Re : PApplet's PGraphics instance

$
0
0
Unless it is added to the API, it looks like it is not going to be added to processing.js.

Pomax said on Jan 13, 2013:
→ State changed from “new” to “wont-fix”
"g" is not part of the Processing API, it's the underlying Java graphics class, and should under no circumstances be accessed in a Processing sketch. Doing so "voids your warrant", since you've escaped to plain Java, and all bets are off. Processing.js will not support the full Java API or its class and method hierarchies, only Processing's API.


I can appreciate his hesitation to include it for the reasons given, but if 'g' is here to stay (and I believe it has been around for a long time), how can we petition to make it part of the API or get 'blessed' in some other way?

Re : PApplet's PGraphics instance

$
0
0
There are 2 forked philosophies here.
  1. Make a pure Processing API. Everything else must be cut off, even though that would be easy cheesy to implement. Like System.out.println() acceptable as println() is a big no-no.  :D
  2. Try to convert everything which is relatively feasible to Processing API. Be it Java, Pyhton, Ruby, etc. Make Processing API running on that environment as complete, comfortable and flexible as possible.


Re : Processing 2.0 video alpha channel

$
0
0
Hey Daniel,

thank you for your support!

I tried this:

  1. import processing.video.*;
    Movie img, maskImg;

    void setup() {
      size(640,360);
      background(0);
      frameRate(25);
      maskImg = new Movie(this, "gimsech_1.mp4");
      img = new Movie(this, "gimsech_a.mp4");
      img.play();
      maskImg.play();
      img.mask(maskImg);
    }

    void draw() {
      image(img, 0, 0);
    }

    void movieEvent(Movie m) {
      m.read();
    }


I get this error:
  1. mask() can only be used with an image that's the same size.

The Videos are the same size and length.
I also wanted to try this out. But it doesn't work.

Did I do something wrong or does it just don't work?

cheers
gimsech

Re : Processing 2.0 video alpha channel

$
0
0
What I tried now:

  • I tried to use the same Video twice:  
  1.   maskImg = new Movie(this, "001.mp4");
      img = new Movie(this, "001.mp4");
      img.play();
      maskImg.play();
      img.mask(maskImg);
            → no luck (mask() can only be used with an image that's the same size)

  • I tried to use the same Movie instance:
  1.   img = new Movie(this, "001.mp4");
      img.play();
      img.mask(img);
            → no luck, because there wasn't a alpha channel effect. It only displayed the Video itself.
  • I created a *.avi File with an alpha channel inside → no luck
  • And I tried all this with a *.mov and a *.mp4
It worked with an *.avi an alpha channel inside, like this:
  1.   maskImg = new Movie(this, "gimsech.avi");
      img = new Movie(this, "gimsech.avi");
      img.play();
      maskImg.play();
      img.mask(maskImg);
BUT: my video is now upside down...

I'm working with Processing 2.0b7.

Re : Processing 2.0 video alpha channel

$
0
0
hi rob,


I have done this before with an Animation compressed .mov file. the filesize gets pretty beastly but it does support the alpha channel. I posted this class on this other forum thread, it should do what you need:


  1. import processing.opengl.*;
  2. import codeanticode.gsvideo.*;
  3. import codeanticode.glgraphics.*;

  4. public class BGvideo {

  5.   GSMovie myMovie;
  6.   GLTexture tex;

  7.   public BGvideo (String videoFile, PApplet app) {

  8.     app.registerDraw(this); 

  9.     myMovie = new GSMovie(app, videoFile );
  10.     tex = new GLTexture(app);
  11.     myMovie.setPixelDest(tex);
  12.     myMovie.loop();
  13.   }
  14.   public void draw () {
  15.     myMovie.read();
  16.     if (tex.putPixelsIntoTexture()) {
  17.       background(255, 0, 0);
  18.       image(tex, 0, 0, 1920, 487);
  19.     }
  20.   }
  21. }

pfd export a specific area / box

$
0
0
hello everyone. I'm a beginner at processing, so I'm pretty sure my question can be answered pretty quickly :)
so, i trying to figure out this task:

in my program there should be a box or area ( let's take for example a rect 500 x 500 px) and my control-field on the left side of the program via controlP5.

if i press the button "save", there should be 1 pdf generated, with all the information from / inside of this 500 x500 px box, without the control filed.

how can this be acchived?
thanks for any help!

Advanced GLSL - pass 1D, 3D and float textures form processing?

$
0
0
Hi,
I was looking at shader examples in processing (especcially "landscape"), and its pretty cool. I already made shaders which raycast (or raymarch) big smooth 3D landscale generated on GPU from 2D texture using bicubic interpolation.

I would like to use power of GPU processing more. I have in mind 2 things which I want to program in future:
  1. Rendering of volumetric data using raymarching algorithm (some sciencetific visualization of electron density)
  2. Using GLSL for solving partial differential equations (like Fluid navier stokes example in processing) 
For that I would probably need
  1.  3D and 1D texture. I know that in GLSL language is also sampler1D and sampler3D which I can in principle use to pass int[] and int[][][] data arrays into GLSL and than read numbers from it using texelFetch() however I don't know how to pass 1D or 2D texture into glsl from processing. Currently I pass all textures to shader as PImage - like myPShader.set("texData", myPImge ). Is there any general way how to do that? Does processing openGL interface implement all openGL features (up to which version 2.0 3.0 )? 
  2. For more precise computations I would prefer pass texture as float arrays (32 or 64 bit) rather than images (where each pixel stores 4x 8bit numbers R,G,B,A). Also I would like to simply pass rather float array float[], float[][], float[][][] rather than converting it to PImage ( using obstructions like loadPixels(); updatePixels();) and than convert it back inside the shader.
Before I spend to much time searching or figuring out how processing interface to OpenGL is working, I would like to know the limitations of current implementation. What is possible and what is not? And if there is possible any workarround in case of features are missing in interface but are in principle possible with the version of OpenGL which is supported by the libraries?

Re : Identifying sounds from minim audio input

$
0
0
I cannot answer your question, but I have some remarks on the form:
- You post to Programming Questions, so you have a question ("how can I do that?"). Then don't change the topic type to Discussion.
- The question is for a core library, so post it there. I move the topic from Programming Questions, which is, BTW, more for questions about code you show, not generic questions (there, I move them to the General Discussion section).
Thanks for understanding.

Re : pfd export a specific area / box

$
0
0
It doesn't work like this: to make a PDF file, you must first tell to record the drawing, then to draw. No magical "save" button...

Re : No font in exported PDF

$
0
0
Having had nothing but problems trying to install necessary dependencies for pycairo and other flavors of cairo, I considered what you said about the fonts being saved as stroked glyphs. That's it. I used a downloaded obscure font that no system is likely to have installed and then uploaded the resulting PDF to several mobile devices. The font showed beautifully and was fully scalable. So no need for embedded fonts. Problem eliminated.


Here's the PDF.

Transparency and resolution problems with exported PDF

$
0
0
I am trying to create a PDF with image content that has a transparent background. I have tried various methods with disappointing results.

I tried the direct-to-pdf beginRecord(PDF, "filename.pdf") method:

  1. import processing.pdf.*;
  2. void setup() {
  3.     size(580, 580);
  4.     noLoop();
  5.     beginRecord(PDF, "image_test_direct_pdf.pdf");
  6. }
  7. void draw()  {
  8.     PImage img; 
  9.     img = loadImage("moon.0096_cr.png");
  10.     imageMode(CENTER);
  11.     background(0);
  12.     pushMatrix();
  13.         translate(width/2, height/2);
  14.         image(img,0,0,width/4, height/4);
  15.     popMatrix();
  16.     endRecord();
  17. }


This looks great and has 180ppi resolution but the transparency has been replaced with opaque gray.

The buffered pdf surface (PGraphicsPDF) createGraphics(width, height, PDF, "filename.pdf") method:

  1. import processing.pdf.*;
  2. PGraphicsPDF pg;
  3. void setup() {
  4.     size(580, 580);
  5.     pg = (PGraphicsPDF) createGraphics(width, height, PDF, "image_test_pdf_createGraphics.pdf");
  6.     noLoop(); //     Stops Processing from continuously executing the code within draw()
  7. }
  8. void draw()  {
  9.     beginRecord(pg);
  10.         PImage img; 
  11.         img = loadImage("moon.0096_cr.png");
  12.         imageMode(CENTER);
  13.         image(img, width/2, height/2);
  14.         pg.imageMode(CENTER);
  15.         pg.background(0);
  16.         pg.pushMatrix();
  17.             pg.translate(width/2, height/2);
  18.             pg.image(img,0,0,width/4, height/4);
  19.         pg.popMatrix();
  20.     endRecord();
  21. }



Interestingly enough, this also looks just as good but Acrobat is showing only 72ppi. What's up with that?! Same situation with the transparency.

The off-screen buffer createGraphics(width, height) method:

  1. import processing.pdf.*;
  2. PGraphics pg;
  3. void setup() {
  4.     size(580, 580);
  5.     pg = createGraphics(width, height);
  6.     noLoop(); //     Stops Processing from continuously executing the code within draw()
  7. }
  8. void draw()  {
  9.     pg.beginDraw();
  10.         PImage img; 
  11.         img = loadImage("moon.0096_cr.png");
  12.         pg.imageMode(CENTER);
  13.         pg.background(0);
  14.         pushMatrix();
  15.             pg.translate(width/2, height/2);
  16.             pg.image(img,0,0,width/4, height/4);
  17.         popMatrix();
  18.     pg.endDraw();
  19.     image(pg,0,0);
  20.     pg.save("image_test_createGraphics.png");
  21.     beginRecord(PDF, "image_test_createGraphics.pdf");
  22.         image(pg, 0, 0);
  23.     endRecord();
  24. }



Now transparency is being preserved but the resolution is unacceptable. Again it is showing as 72ppi and this time it looks it...

On the PDF Export library page it says

Images don't look great, mostly because of the difference of expectations in how a PDF should look (scalable and high res) versus what happens when image data is written to it at 72 dpi.

And yet in the first example above, image data was written at 180ppi. I don't know why 72ppi would be the default. It is ridiculously low even for a small-screen monitor. But for a PDF which will likely be printed, 300-1200 ppi is the norm. Why isn't this adjustable? Is there a hack that can make it adjustable?

The PDF version of the exported files is 1.4 (Acrobat 5.x), which supports an alpha channel. I even made a PDF of the same version with the original image and the background was transparent. This also should be programmable. Is there a hack for this?

So I don't know where to go from here. It's either horrible resolution or no transparencies. I can't proceed with either situation. Does anyone know a work-around that will give me high resolution AND transparency at the same time. I still need scalable vector graphics as well for text and graphics objects so a high-res image is not an option.


Blending very large images: performance, memory

$
0
0
I need to alpha blend 2700x1600 images at runtime.  Not totally surprisingly, I'm having problems keeping my framerate up.  I've tried doing the blending on an offscreen buffer, but that hasn't seemed to help much if any.  Are there any general strategies for working with images this large that might apply to this situation?  Something to leverage the graphics card as much as possible, perhaps?

I'm also having a bit of trouble managing memory; each of these images uncompressed is ~17MB (2700x1600x4 bytes), and there are a total of ~60 images I'll be blending (not all simultaneously!).  I have strategies in mind for the memory issue that are outside the scope of this question, but I include it here in case there is a clever way to balance memory usage between the computer's memory and the graphics card.

Based on my digs into the source, it does seem that Processing (PGraphicsOpenGL specifically) is using JOGL internally for PApplet.image(), so that optimization at least is already happening.

Advice in raw JOGL is not as nice as Processing code, but I can probably thrash my way through it if there's a JOGL route.

Basic strategy (very simplified code) as of right now is:
  1. PImage a = loadImage("imageA.png");
  2. PImage b = loadImage("imageB.png");
  3. PGraphics buffer = createGraphics(width, height, OPENGL);

  4. void draw () {
  5.   buffer.beginDraw();
  6.   buffer.tint(255, 200);
  7.   buffer.image(a, 0, 0);
  8.   buffer.tint(255, 100);
  9.   buffer.image(b, 0, 0);
  10.   buffer.endDraw();
  11.   image(buffer, 0, 0);
  12. }

Re : Blending very large images: performance, memory

$
0
0
Can´t you do that with OpenCV? OpenCV is really quick processing images.

Re : pfd export a specific area / box

$
0
0
Hi, since controlP5 is by default drawn after processing has finished its own drawing routine, the following example shows you how to save a pdf without controlP5 elements.


  1. import controlP5.*;
  2. import processing.pdf.*;

  3. // using controlP5 version 2.0.4 with processing 2.0b7
  4. ControlP5 cp5; 

  5. boolean record;

  6. void setup() {
  7.   size(800,600);
  8.   
  9.   cp5 = new ControlP5( this );
  10.   
  11.   Bang b = cp5.addBang( "save" )
  12.               .setPosition( 20 , 20 )
  13.               .setSize( 100 , 100 )
  14.               ;
  15.               
  16.   b.getCaptionLabel()
  17.    .align( CENTER , CENTER )
  18.    ;
  19.   
  20. }

  21. void draw() {
  22.   background( 230 );
  23.   
  24.   pushMatrix();
  25.   if( record ) {
  26.     beginRecord( PDF , "grid-" + frameCount + ".pdf" );
  27.   }
  28.   
  29.   fill( 0 );
  30.   translate( 200 , 50 );
  31.   
  32.   for( int i = 0 ; i < 250 ; i++ ) {
  33.     float f = sin( ( frameCount + i ) * 0.01 );
  34.     pushMatrix();
  35.     translate( ( i * 50 ) % 500 , ( i / 10 ) * 20 );
  36.     rotate(f);
  37.     rect( 0 , 0 , 50 , 2 );
  38.     popMatrix();
  39.   }
  40.   if( record ) {
  41.     record = false;
  42.     endRecord();
  43.   }
  44.   popMatrix();
  45.   
  46. }

  47. void save() {
  48.   record = true;
  49. }


Re : No font in exported PDF

$
0
0
I don't understand how you did this one. Processing? iText? PyCairo? Something else? Any special incantation needed?
Viewing all 1768 articles
Browse latest View live