We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › progressive loadImage
Page Index Toggle Pages: 1
progressive loadImage (Read 878 times)
progressive loadImage
Apr 2nd, 2007, 6:09pm
 
Hi everybody.
I would like to start using Processing for visualizing images.

I'm not familiar with programming, I simply copy and paste, and in most of cases I can't understand how things works.

I'm trying to build a visualizer to navigate throught images in a 3d ambient.

I would like to have a command to load sequence of images, so I can update, add, or remove the jpg files in the folder; and when I start Processing applet it loads them automatically.

Maybe there can be some function to put in loadImage()input ??

Thanks for your suggestions.
Ale.
Re: progressive loadImage
Reply #1 - Apr 2nd, 2007, 7:49pm
 
you can just number them (imageName0.jpg to imageName11.jpg), put them in the data-folder next to your .pde file (Sketch->"Show Sketch Folder" in Processing or just drag them into the Processing-window) and then:

Code:

PImage images[];
int numberOfImages = 12;

void setup() {
size( 300, 300 );
images = new PImage[numberOfImages];
for ( int i=0; i < numberOfImages; i++ )
{
images[numberOfImages] = loadImage("imageName"+i+".jpg");
// loades images 0-11:
// imageName0.jpg
// ...
// imageName11.jpg
}
}

int counter = 0;
void draw ()
{
image(images[counter],0,0);
counter++;
counter %= numberOfImages; // wrap around
}


F
Re: progressive loadImage
Reply #2 - Apr 3rd, 2007, 11:03am
 
thank you for the answer.


It returns me the error:

java.lang.ArrayIndexOutOfBoundsException: 4

at Temporary_4316_2800.setup(Temporary_4316_2800.java:9)

at processing.core.PApplet.handleDisplay(PApplet.java:1281)

at processing.core.PGraphics.requestDisplay(PGraphics.java:564)

at processing.core.PApplet.run(PApplet.java:1450)

at java.lang.Thread.run(Unknown Source)


Anyway, I have not seen a similar previous post; I copied that code and it works.
My problem now is that I can't make the images interactive in 3d, not rotating or draggable, because the end of the counter makes the screen fixed.
Can I solve the problem, considering that I would like to have some random effects?

Thank you a lot.
(how many problems when a product designer like me try to be a graphic designer..)


Re: progressive loadImage
Reply #3 - Apr 3rd, 2007, 11:27am
 
Code:

whoopsi, this line:

images[numberOfImages] = loadImage("imageName"+i+".jpg");

should be:

images[i] = loadImage("imageName"+i+".jpg");

sorry.

nor sure what you mean with "counter makes the screen fixed" ... the counter was just an example to get you going. you can update it once a user clicks or presses a key .. that's up to you. i think the first thing for you to do is to exactly outline what you want to do. then split that into solveable sub-steps, build test-sketches and in the end merge everything together.

sure you can apply any effects, filters, whatnot to the image:
Code:

void draw ()
{
pushMatrix()
translate( random(width), random(height) );
rotate( random( PI ) );
filter( (int)random(11,18) );
image(images[counter],0,0);
popMatrix();
counter++;
counter %= numberOfImages; // wrap around
}

// the numers in filter can be found here:
// PConstants (look for "filter")

Re: progressive loadImage
Reply #4 - Apr 4th, 2007, 12:41pm
 
thank you again for the quick answer,

you're right: I have to clear my mind and freeze what I want to do.

Talking about freezing... there is a last thing (by now) I would like to ask: in "void draw()" when I set a background I can navigate in the space and the applet is always refreshed, but the images are continuously flashing.
Can you tell me how to solve the problem?
I hope this will be the last stupid question.

Starting from zero, in few days I learned a lot, and I like processing more and more.
Thank you.

the code is:
Quote:


import processing.opengl.*;

import damkjer.ocd.*;

Camera camera1;

PImage images[];
int numberOfImages = 4;



void setup() {
 size(800, 600, P3D);
 frameRate(50);

 // little buggy camera constructor from OCD library
 camera1 = new Camera(this,
                      200.0, 0.0, 500.0,
                      200.0, 50.0, -500.0,
                      0.0, 1.0, 0.0,
                      radians(PI/7), (width/height), 1.0, 1000.0);
  camera1.zoom(radians(130) / 2.0);    

 images = new PImage[numberOfImages];
 for ( int i=0; i < numberOfImages; i++ )
 {
   images[i] = loadImage("imageName"+i+".jpg");  
   // loades images 0-11:
   // imageName0.jpg
   // ...
   // imageName11.jpg
 }
}

int counter = 0;    


void draw() {
 background(255);

 camera1.feed();
 cameraNavigation();

{
   pushMatrix() ;
   translate(counter*100, 0 );
   image(images[counter],0,0,100,100);  
   popMatrix();
   counter++;  
   counter %= numberOfImages; // wrap around  
}  


}

void cameraNavigation() {
 if (!mousePressed){
   //
 } else if (mouseButton == LEFT) {
   camera1.circle(radians(mouseX - pmouseX) / -2.0);
   camera1.arc(radians(mouseY - pmouseY) / -2.0);
 } else if (mouseButton == RIGHT) {
   camera1.zoom(radians(mouseY - pmouseY) / 2.0);
 } else if (mouseButton == CENTER) {
   camera1.look(radians(mouseX - pmouseX) / 6.0, radians(mouseY - pmouseY) / 2.0);
 }
}







Re: progressive loadImage
Reply #5 - Apr 4th, 2007, 12:58pm
 
flashing you mean jumping to the next or are there distortions?

if they rotate too fast you can change when the counter is updated (keyPressed for example) ..

happy to help. keep up the faith, once the initial stones are out of the way you will get up to speed.

F
Re: progressive loadImage
Reply #6 - Apr 4th, 2007, 1:22pm
 
They jump to the next: If I set a low framRate I can see that it loads an image, then the following one but the previous disappears. I would like to see them always.

thanks
Re: progressive loadImage
Reply #7 - Apr 4th, 2007, 2:06pm
 
something like this?

Code:

for (int i =0; i< numberOfImages; i++ )
{
pushMatrix();
translate(i*100, 0 );
image(images[i],0,0,100,100);
popMatrix();
}


F
Re: progressive loadImage
Reply #8 - Apr 4th, 2007, 2:13pm
 
GREAT! so easy
thank you very much,

I will tell you about future results.
Page Index Toggle Pages: 1