Android Filepath Issue

Hi, I have a Android Processing sketch that used to work a few years ago but I need to update it and can’t get it to run. It seems like there is a problem with having the path in the filename string but this used to work…

for (int i=0; i<numFrames; i++) {
    String imageName = "sequences/" + basename + "_pixelData/pixelData" + nf(i, 5) + ".png";
    imageSequence[i] = loadImage(imageName);
    println("Image "+imageName+" was loaded as "+imageSequence[i]);
  }

Any idea how to work around this problem? Ideally I would like to keep my code as is and figure out how to make it run on my device.

Thanks

Phil

FATAL EXCEPTION: GLThread 787
   Process: processing.test.pixelpetal_v09, PID: 1579
   java.lang.IllegalArgumentException: File sequences/allseq_pixelData/pixelData00000.png contains a path separator
       at android.app.ContextImpl.makeFilename(ContextImpl.java:2366)
       at android.app.ContextImpl.getFileStreamPath(ContextImpl.java:1120)
       at android.content.ContextWrapper.getFileStreamPath(ContextWrapper.java:191)
       at processing.core.PApplet.sketchPath(Unknown Source)
       at processing.core.PApplet.createInputRaw(Unknown Source)
       at processing.core.PApplet.createInput(Unknown Source)
       at processing.core.PApplet.loadImage(Unknown Source)
       at processing.test.pixelpetal_v09.pixelpetal_v09.loadImageSequence(pixelpetal_v09.java:96)
       at processing.test.pixelpetal_v09.pixelpetal_v09.setup(pixelpetal_v09.java:116)
       at processing.core.PApplet.handleDraw(Unknown Source)
       at processing.opengl.PGLES$AndroidRenderer.onDrawFrame(Unknown Source)
       at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
       at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)

@philspitler===

This is the fileSeparator standard issue (and i have already put answers for it in the “old” forum); till your images are in the data folder at the first level loadImage() works but if you are using subfolders it fires this error ; in order to get rid of it you have to use android AssetManager and list your subfolders (or folders/subfolders…): it will return an array of all the files inside them and so you can get your image using loadImage(myarray[i]). Of course i suppose that your images are not in the external sd card but in your app!

Please cross-link your post: https://forum.processing.org/two/discussion/28082/filepath-issue#latest

I suggest you continue any other discussion in this forum.

****EDIT: Additional relevant links parallel in APDE: https://github.com/Calsign/APDE/issues/54#issuecomment-413367412

Kf

@Andres This is a suggestion of how to handle files with dataPath(). @Akenaton has a good point with his approach. I have a suggestion in the above link. I have to think a little bit harder to see how it could be implemented in the source code, to be able to use dataPath the same way as in processing Java.

Kf

@kfrajer, thanks so much for your help… this works perfectly…

I’m linking the thread again in case others have the same issue…

Phil

@kfrajer I spoke too soon…

While the code works, it is really slow…

I am using the code read an image sequence and the animations that usually run at 24fps are running at half of that.

The images are tiny PNG files (approx 300 bytes each)…

Any idea how I could increase the performance?

Cheers.

Phil

You would need to put together an MCVE to be able to reproduce the problem. Maybe check if you are working your images too much. For instance, are you actively resizing your images in draw()? Are you loading files in this function? Very hard to make suggestions without seeing your actual code.

Kf

I am scaling them so I can see them for debug purposes…

Let me try without that and see what happens… the images are only 394x7 pixels so they are hard to see…

I’ll report back…

Thanks

Phil

Hi, @kfrajer I tracked down the slowness to Control P5.

I created a new post as this is a different issue.

Thanks,

Phil