We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Running P2.0.3 and Android SDK, Peasycam library. My code loads an image from the sketch's own folder. Runs fine in Java mode. When I run it on the emulator everything seems to go well, Processing installs the app on the Android emulator, and it trys to start and simply gives an "unexpectedly stopped" error on the emulator screen, no further details. I think the issue is the image load, but other than in my sketch folder or in the DATA folder, I don't know where I should place the file for the Android app. I can run other apps in the emulator so it's wired correctly.
What am I missing here....?
import peasy.*;
PImage b;
PeasyCam cam;
color[] dots;
void setup(){
println("DATAPATH "+dataPath(""));
size(480,800, P3D);
b = loadImage("example.jpg");
size(b.width, b.height, P3D);
noSmooth();
cam = new PeasyCam(this, 80,-10,-10,150);
b.filter(GRAY);
evalPixels();
}
void draw(){
background(255);
drawMatrix();
}
void drawMatrix(){
for (int r = 0; r < b.height; r++){ // step through rows (lines) of pixels in image
for (int p = 0; p < b.width; p++){ // step through each pixel value in row
int loc = r + p * b.width; // array ID for each pixel
float x = r;
float y = p;
float z = (dots[loc]/1000000)*-1;
point(x,y,z);
}
}
}
void evalPixels(){
b.loadPixels();
dots = b.pixels;
for (int i = 0; i < dots.length; i++){
print((dots[i]/100000)*-1 + " ");
}
}
Answers
Your code doesn't seem to have a problem loading image. But rather there's some issue in drawMatrix() method.
I tried to run it on my machine and even in Java mode it yield error (obviously I put some example.jpg into the data folder):
Works fine on my end in Java mode. Perhaps it's the image, here's the one I use. I should add an algorithm to get the pixel value range of the image loaded and then figure out the correct divisor. In the meantime it will work on this image:
Hello, Have you fix your problem, hondaman900?