Pi 3 extremely slow performance drawing images

-a- yes, fullscreen apps might get slow.
why not start 800*800

-b- put a FPS show into your sketch
or play with this tool

 float rset=120, r;
int x = 0;
int w = 400;
int h = 200;
int grid=20, many = grid*grid;
boolean stressenable=true;

void settings() {
  size(w, h); // default use JAVA2D 
  //  size(w, h,FX2D);
  //  size(w, h,P2D);
  //  size(w, h,P3D);
}

void setup() {
  frameRate(rset);
  background(200, 200, 0);
  numinfo();
  sysinfo();
  println("\nstresstest ( "+grid+"*"+grid+" = "+many+" ) points, [+][-] grid +-5" );
}

void draw() {
  surface.setTitle("SYS INFO set "+rset+": "+ nf(r, 0, 1)+" FPS" );
  if ( stressenable ) stress();
  r = frameRate;
  if ( r > 30 )      stroke(0, 200, 0); 
  else               stroke(200, 0, 0);
  line(x, height-2, x, height-2-r);            // FPS graph
  x++;
  if ( x > width ) { 
    x = 0; 
    background(200, 200, 0);
  }
}

void stress() {
  push();
  for ( int i=0; i<grid; i++) {
    for ( int j=0; j<grid; j++) {
      stroke(random(255), random(255), random(255) );
      point(5+i, 5+j);
    }
  }
  pop();
}

void sysinfo() {
  println( "__SYS INFO :");
  println( "System     : " + System.getProperty("os.name") + "  " + System.getProperty("os.version") );// + "  " + System.getProperty("os.arch") );
  println( "JAVA       : " + System.getProperty("java.home")  + " rev: " +javaVersionName);
  //println( System.getProperty("java.class.path") );
  //println( "\n" + isGL() + "\n" );
  println( "OPENGL     : VENDOR " + PGraphicsOpenGL.OPENGL_VENDOR+" RENDERER " + PGraphicsOpenGL.OPENGL_RENDERER+" VERSION " + PGraphicsOpenGL.OPENGL_VERSION+" GLSL_VERSION: " + PGraphicsOpenGL.GLSL_VERSION);
  println( "user.home  : " + System.getProperty("user.home") );
  println( "user.dir   : " + System.getProperty("user.dir") );
  println( "user.name  : " + System.getProperty("user.name") );
  println( "sketchPath : " + sketchPath() );
  println( "dataPath   : " + dataPath("") );
  println( "dataFile   : " + dataFile("") );
  println( "frameRate  : target "+nf(rset, 0, 1)+" actual "+nf(r, 0, 1));
  println( "canvas     : width "+width+" height "+height+" pix "+(width*height));
}

void numinfo() {
  println( "__NUM INFO :");
  println( "byte     "+Byte.SIZE+  " bit | min: "+Byte.MIN_VALUE+   "\t\t\t max: "+Byte.MAX_VALUE);
  println( "short   "+Short.SIZE+  " bit | min: "+Short.MIN_VALUE+  "\t\t\t max: "+Short.MAX_VALUE);
  println( "int     "+Integer.SIZE+" bit | min: "+Integer.MIN_VALUE+"\t\t max: "  +Integer.MAX_VALUE);
  println( "long    "+Long.SIZE+   " bit | min: "+Long.MIN_VALUE+   "\t max: "    +Long.MAX_VALUE);
  println( "float   "+Float.SIZE+  " bit | min: "+Float.MIN_VALUE+  "\t\t\t max: "+Float.MAX_VALUE);
  println( "double  "+Double.SIZE+ " bit | min: "+Double.MIN_VALUE+ "\t\t\t max: "+Double.MAX_VALUE);
}

void keyPressed() {
  if ( key == 's' ) stressenable = ! stressenable;
  if ( key == '+' ) {
    grid +=5;
    many = grid*grid;
    println("stresstest ( "+grid+"*"+grid+" = "+many+" ) points" );
  }
  if ( key == '-' ) {
    grid -=5;
    many = grid*grid;
    println("stresstest ( "+grid+"*"+grid+" = "+many+" ) points" );
  }
}


if you need me to test your code here, need some time.

1 Like

Hey! Thanks for replying! I just edited the post because I realized I was an idiot and forgot that part.

This is the image in question: https://imgur.com/a/QBVnmXG

I really want this to run at 1280x800, as that is the resolution of the screen. This is for a glass cockpit for my ultralight aircraft :slight_smile:

This is what it looks like right now:

Fullscreen actually improved the FPS slightly, I’m working on trying to figure out how to add an FPS counter to see how much it did…

2 Likes

please play my test tool

I just tried to run it, and it’s complaining that push() and pop() no longer exist?

ok,
lets start from the beginning,
? system hardware
? system software
? installed processing


you might study my picture,
but i posted it also for exactly that reason
you see my RASPBIAN sysinfo
processing version
Processing sysinfo

but just to be exact, it is the old / first buster setup updated,
( not the latest RASPBIAN / that i am still testing )
( all about the video GLvideo library problems now )

1 Like

Thank you so much for the help. It’s much appreciated. I’ve been working on this on and off for a while so I figure it is probably slightly out of date. Also I’m a huge noob at processing, it seems, so I might be a bit slow.

Main system: Win10, i7 6700k, blah blah, processing 3.4.

Problem system: Pi 3+, and whatever the raspbian version that comes pre-downloaded with processing 3.4 was… I’m not sure how to check.

I can see you’re on 3.5.3, which is probably part of the issue. I shall… go and update things, heh. Be right back with that.

1 Like

now i just look at that picture PNG you use,
1000 * 2500
for 2 color filled rectangle with some lines and numbers easy to do with FOR loop.
loose the picture!

yes, even with

void setup() {
  //fullScreen();
  size(500,500);

and

void draw() {
//  drawhorizon();
  background(0);
  text("FLUSI "+nf(frameRate,0,1)+" fps",10,10);
  drawhorizon2(200,60);

i only see 11 fps.

1 Like

It appears the latest official raspbian + processing download is still 3.4, so I’m not sure how to update it manually beyond that. (Not super experienced with linux)

Okay, I can try to implement it manually. I used to draw objects as a bunch of individual primitives, but that was slow as well. Please try this example: https://www.dropbox.com/s/2ksm79g3hl8kf2o/pi_dash_test.zip?dl=0

It runs great on my desktop, but only at 10.5fps on the pi.

Is the Pi just very slow or am I doing something stupid?

Thank you for being so fast to respond!

or both, sorry i not study your code,
but you should start with a new project
testing about FPS, fullscreen or
on a RPI 3B plus

void setup(){
 fullScreen();  // 13.5 fps
 //size(1920,1080);  // 12.3 fps
 //size(1000,1000);  // 23.3 fps
 //size(500,500);    // 59.fps

}

and start draw first items to get a better feeling.

Yeah… I might do that. Just don’t even really have much going on in this one either, and its already lagging. I removed the image and simply replaced it with a rectangle, and it goes just as slowly.

When I am talking about fps, in terms of the problem, I mean that it runs at a locked 30fps no problem on my win10 desktop, but struggles on the pi when uploaded and ran on it. Windowed, fullscreen, no matter what on the pi, it goes slowly. CPU usage on the pi also never goes high, right now its at 30% while running the sketch.

Try this:

//mfd test for aircraft

PGraphics ghorizon;

float horizH = 250;
float horizR;
PImage img;
float testx;
float testy;


  
void setup() {
  size(1280,800);
//  img = loadImage("artificial horizon 2.png");
  ghorizon = createGraphics(550, 500);
  drawbg();
}

void draw() {
//  drawhorizon();
  drawhorizon2(200,60);
  testx = sin(float(frameCount)/100)*100;
  testy = sin(float(frameCount)/150)*100;
}

void drawbg() {
  background(0);
}

void drawhorizon2(int x,int y) {
  ghorizon.beginDraw();
    ghorizon.background(0);
    ghorizon.translate(275,250);
    ghorizon.rotate(radians((testx))/4);
    ghorizon.translate(0,testy);

//    ghorizon.image(img,-500,-1250);
  ghorizon.stroke(255);
  ghorizon.fill(150);
  ghorizon.rect(0,0,400,400);
  ghorizon.endDraw();
  
  
  image(ghorizon,x,y);
  
  stroke(0);
  noFill();
  strokeWeight(20);
  rect(x-10,y-10,570,520,40);
  
  stroke(255);
  strokeWeight(12);
  line(x+150,y+250,x+220,y+250);
  line(x+220,y+250,x+220,y+270);
  line(x+330,y+250,x+400,y+250);
  line(x+330,y+250,x+330,y+270);
  
  stroke(0);
  strokeWeight(8);
  line(x+150,y+250,x+220,y+250);
  line(x+220,y+250,x+220,y+270);
  line(x+330,y+250,x+400,y+250);
  line(x+330,y+250,x+330,y+270);
  
  strokeWeight(3);
  stroke(255,0,255);
  line(x+275,y+175,x+275,y+325);
  line(x+200,y+250,x+350,y+250);
}

LOL

lets say, processing cooks on one burner.

so unless your JOB could be divided in THREAD s
the single CPU speed will be your limit.
( and sorry, i never play about overclocking )
( i use from terminal htop )

1 Like

Ah, understood. I will do that and see what the result is.

While simply trying to wiggle a rectangle around, this is the htop picture:

2 Likes

yes, and fullscreen ( plus ALT TAB works )
( i work remotely VNC )

1 Like

Interesting… Even the act of drawing a rectangle and moving it around completely uses up a core on the pi. I’m not even sure how to deal with that other then ditching processing and trying to learn something else.

I can’t simplify it down more then just drawing a rectangle, which still lags it. I feel like this doesn’t make any sense. I guess I’ll try again from scratch.

Thank you for your help.

this would be python webserver on RPI
with dynamic data from Arduino ( PID control… )
here

or python app only
here

from
http://kll.engineering-news.org/kllfusion01/articles.php?article_id=125

but i would not dare to compare processing JAVA app with python app or even
python web app speed wise, too many parameter…

1 Like

That looks pretty slick! Did you make that?

I’ve never tried to use python before, so that will be a bit interesting. Do you have any pointers on where to start? (graphics libraries to use, that kind of thing, I googled it and there appears to be a lot…)

did you understand what to fix? i have the Raspberry pi 4 (4GB) and have this kind of problems too.

Not really. But I did find switching to P3D helped dramatically with speed. Also I’ve found that whatever Processing installs on the Pi 4 runs like garbage compared to the 3b/3b+… its clearly not ported properly just yet.

@ITman496 There is no longer any official support (by processing.org) for the RaspberryPI. Gottfreid Haider who was providing support, has left processing.org. He did some mods to port processing to the RaspberryPI (specifically RaspberryPI3B+ running Stretch using Oracle JDK8). There is no support for Buster distro, and definitely no support for RaspberryPI4. However I have found if I remove the Gottfreid Haider mods (essentially the shader mods) and use the FakeKMS graphics driver in place of the default driver, I get good results with PiCrate. It may not suit you, because in place of processing IDE I use Geany and you need to learn ruby. But I mention this as I am sure vanilla processing could be made to work well on RaspberryPI4 and Buster. For the interested, I develop PiCrate here.

2 Likes

Interesting! I have no actual clue how to do that myself but I hope someone has the desire to run vanilla processing on the pi4 who does will pick it up at some point! In the meantime if I need more power I’ll likely try an intel NUC or something similar.