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 & HelpPrograms › position sensitive device
Page Index Toggle Pages: 1
position sensitive device (Read 489 times)
position sensitive device
Oct 31st, 2007, 6:33pm
 
Iambeginner.do not succeed this sketch.
I wanana advise.Please???



import processing.opengl.*;
import processing.gainer.*;
import java.lang.Thread;

Gainer gainer;//position sensitive device
PImage img;      
int cellsize = 1;  
int COLS, ROWS;  
class ReceiverThread extends Thread
{
 void run() {
   while (isAlive()) {
     gainer.peekAnalogInput();

     try {
       sleep(10);
     } catch (Exception e) {
     }
   }
 }
}
void setup(){
gainer = new Gainer(this);


size(1000, 646, P3D);
 
 img = loadImage("yama.jpg");    
 COLS = width/cellsize;            
 ROWS = height/cellsize;          
 colorMode(RGB,255,255,255,100);  
}
void draw()
{
 background(0);
 // Begin loop for columns
 for ( int i = 0; i < COLS;i++) {
   // Begin loop for rows
   for ( int j = 0; j < ROWS;j++) {
     int x = i* gainer.analogInput[0] + cellsize/300; // x position
     int y = j* gainer.analogInput[0] + cellsize/300; // y position
     int loc = x + y*width;          
     color c = img.pixels[loc];      
     
     float z = ( gainer.analogInput[0] / (float) width) * brightness(img.pixels[loc]) - 300.0f;
     
     
     pushMatrix();
     translate(x,y,z);
     fill(c);
     noStroke();
     rectMode(CENTER);
     rect(0,0,cellsize,cellsize);
     popMatrix();
     
     
   }
 }
}

void keyPressed() {
 save("yama.jpg");
 }
Re: position sensitive device
Reply #1 - Oct 31st, 2007, 6:49pm
 
and what's the problem? what is not working? can you post the errors from the console?

thanks
F
Re: position sensitive device
Reply #2 - Nov 1st, 2007, 1:16am
 
The check of the device was completed.
It is suspected whether this portion is amusing.
int x = i* gainer.analogInput[0] + cellsize/300; // x position
int y = j* gainer.analogInput[0] + cellsize/300; // y position
int loc = x + y*width;      
color c = img.pixels[loc];  
 
float z = ( gainer.analogInput[0] / (float) width) * brightness(img.pixels[loc]) - 300.0f;
 


this is the error message.
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7

selected port name /dev/cu.usbserial-A500253A
serial port opening ...
Gainer reboot..
Gainer firmware ver. 1.0.1.02
dev:1.0.1 lib:1.0.0
silent mode
configuration: mode1
Gainer ready to Roll.

selected port name /dev/cu.usbserial-A500253A
serial port opening ...

RXTX uucp_lock() /var/lock/LK.003.009.001 is there

initialize error gnu.io.PortInUseException: Unknown Application

gnu.io.PortInUseException: Unknown Application
  at gnu.io.CommPortIdentifier.open(CommPortIdentifier.java:354)

java.lang.RuntimeException: Error inside Serial.<init>()
  at processing.gainer.Gainer.errorMessage(Gainer.java:687)
  at processing.gainer.Gainer.initialize(Gainer.java:189)
  at processing.gainer.Gainer.<init>(Gainer.java:130)
  at processing.gainer.Gainer.<init>(Gainer.java:92)
  at Temporary_7493_6924.setup(Temporary_7493_6924.java:23)
  at processing.core.PApplet.handleDisplay(PApplet.java:1285)
  at processing.core.PGraphics.requestDisplay(PGraphics.java:680)
  at processing.core.PApplet.run(PApplet.java:1454)
  at java.lang.Thread.run(Thread.java:613)
dispose Gainer ..
Experimental:  JNI_OnLoad called.
Page Index Toggle Pages: 1