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 › change value of image with interaction
Page Index Toggle Pages: 1
change value of image with interaction (Read 817 times)
change value of image with interaction
Jan 11th, 2008, 7:43am
 
Hi, im have make a code for interaction with keyboard on photo, but don't run
also i have make the same with video and in this case run good.
Is necessary the function pixel() for image ?

thanks
mauma

Code:



int value = 0;
int post = 0;


// Import the Library
import processing.video.*;
import processing.opengl.*;

// Create an Object of type Capture
Capture myCapture;

void setup()
{
size(720 , 578);

myCapture = new Capture(this, width, height, 30);
}


void captureEvent(Capture myCapture)
{
// Read the captured frame
myCapture.read();
}

void draw()
{




// control of value of BLUR whit the key UP and DOWN

if(keyPressed) {
if (keyCode == UP) {
value = value + 1;

}
}

if (keyPressed) {
if (keyCode == DOWN) {
value = value - 1;
}
}



// Draw the captured frame as an image
image(myCapture, 0, 0);
filter (BLUR,value);


}







Re: change value of image with interaction
Reply #1 - Jan 11th, 2008, 8:00am
 
Please post the code that doesn't run so we can see where is the problem.

This should work :

Code:
PImage myPhoto = loadImage("photo.jpg");

void draw() {
image(myPhoto, 0, 0);
filter (BLUR, value);
}
Re: change value of image with interaction
Reply #2 - Jan 11th, 2008, 8:13am
 
Thanks, but don't visualize the pict, i report all code.
muama

Code:
 int value = 0;
int post = 0;

void setup()
{
size(720 , 578);

}

PImage myPhoto = loadImage("teatro.jpg");

void draw() {
image(myPhoto, 0, 0);
filter (BLUR, value);
}

// control of value of defocus whit the key UP and DOWN

if(keyPressed) {
if (keyCode == UP) {
value = value + 1;

}
}

if (keyPressed) {
if (keyCode == DOWN) {
value = value - 2;
}
}
Re: change value of image with interaction
Reply #3 - Jan 11th, 2008, 9:34am
 
ah. maybe loadImage() should be use in setup().

Code:
int value = 0;
int post = 0;
PImage myPhoto;

void setup() {
myPhoto = loadImage("test.bmp");
}

void draw() {
image(myPhoto, 0, 0);
filter (BLUR, value);

// control of value of defocus whit the key UP and DOWN
if(keyPressed) {
if (keyCode == UP) { value = value + 1; }
else if (keyCode == DOWN) { value = value - 2; }
}
}
Re: change value of image with interaction
Reply #4 - Jan 11th, 2008, 10:41am
 
many thanks ! run good
mauma
Page Index Toggle Pages: 1