• Post Reply Bookmark Topic Watch Topic
  • New Topic

read image in a RasberryPiZerro w take to long in java (BufferedImage)  RSS feed

 
Niklas Karlsson
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i have a Jframe and panel and i set a label (yes a label) to a jpg image (and some timed text..)

in my win PC it takes ~208 ms to make:
//timer start..
BufferedImage img = ImageIO.read(file);
//timer end..


I like to open this in a PasberryPiZerroW or "v3b"
but in the PasberryPi v3 it takes ~2600 ms to make:
//timer start..
BufferedImage img = ImageIO.read(file);
//timer end..


and for the rasberryPiZerroW it takes forever!, i have a timeout that kicks in @15s and it is activated!
if i try to open the image in a atandalone image viewer, the "zerro w" open the image "instantly/no lag"!
(pi uses java 7)

Can i use something more modern and fast?
(and i have difficulty to change type of the BufferedImage, so please: i what to use "BufferedImage "-format..)

I have tryed this code on the PasberryPi v3 :
https://forum.processing.org/one/topic/snippet-crazy-fast-image-loading.html

but it just loads 10 -50% of the picture, i have a loop that trys to open this in this example and take (300ms)..
i change the timer to x100, but is there a better way?



 
 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the size of the image that you are trying to load?
 
Niklas Karlsson
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
only 202.8KiB
 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Niklas Karlsson wrote:only 202.8KiB

I think 200kB is significant since the Raspberry Pi Zero only has 512kB of physical RAM.  Use top or some other utility to see how much memory is being consumed by the OS, JVM, etc.

Is it possible that the OS is swapping to the SD card in order to get more virtual memory?  That would be a very slow operation.
 
Niklas Karlsson
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm..
I read:"
Pi Zerohas:

1GHz, single-core CPU
512MB RAM
Mini HDMI and USB On-The-Go ports
Micro USB power..."

Not 512k?
 
Ron McLeod
Saloon Keeper
Posts: 1562
222
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Niklas Karlsson wrote:Hmm.. 512MB RAM ... Not 512k?

Whoops - of course you're right - not sure where was brain was up to ... 

So, yes, 202.8KiB shouldn't be an issue for RAM.  Do you have any way to benchmark the reading speed from the SD card?
 
Niklas Karlsson
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm no 😕
 
Niklas Karlsson
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use this card:
https://www.electrokit.com/en/memory-card-microsdhc-16gb.52611

"Up to 30MB/s.."
 
Niklas Karlsson
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm, can I use something other class? Faster. ..
 
Joe Ess
Bartender
Posts: 9426
12
Linux Mac OS X Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would not surprise me to hear Java is slow on a Pi Zero.  It is a pretty primitive system.  I have a Pi 2 B handy and did some simple file reading tests.  It appears that the Pi takes about twice as long to read a file compared to my desktop.  I compared it reading files off a thumb drive and the SD card and there did not appear to be a difference.
Are you using the Oracle JDK or OpenJDK?  Once upon a time, OpenJDK had serious performance issues.  I have not seen any in years, however I use Oracle JDK as a matter of course. 
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!