0

I'm creating a program that reads pictures (JPG max size about 10Mb per file) from FlashAir as soon as they're taken, display them in a bigger screen for review and saved them to a local folder. It is paramount to reduce the time from the moment the picture is taken until it is displayed to the user and to prevent loss of quality (they are macro pictures). Now, the camera works with JPG, so changing that is not an option for the moment. All the pictures must be saved locally in the maximum possible quality.

I was wondering what would be the best way to achieve this. Since the FlashAir card is in the camera and moves around, the bottleneck will probably be in the wireless transfer (max speed is 54 Mb/s).

The picture could be displayed withing the Java app or sent to a different app for editing, but I want to reduce I/O operations (I don't want to have to re-read the picture once is saved locally to actually display it).

What is the best way to achieve this using pure Java 8 classes?

My test implementation uses ImageIO.read() and ImageIO.write() methods. The problems I have with this approach is that it takes a long time for the picture to be displayed (it is actually read from the saved folder) and the image is re-encoded and compressed, loosing quality compared to the original file that is in the SD Card.

I feel it should be a way to transfer the bytes very efficiently over the network first and run two parallel processes to save the untouched bytes to disk and decode and display the image (image then could potentially be edited and saved to disk to a different location).

I don't need a fully working example. My main concern is what Java 8 I/O classes are best suited for this job and to know if my approach is the best one to achieve the results.

Edit

After some research I was thinking of using ReadableByteChannel to storage the picture bytes in a ByteBuffer and then pass copies of it to two jobs that will run in parallel: the one saving the bytes would use a FileChannel and the one displaying the image would use them to create an ImageIcon.

I don't know if there is a better/recommended approach.

Marcelo Ruiz
  • 199
  • 9
  • If I understand you correctly, the flashair stuff is completely irrelevant to your question, all you have is a file on a slow media that you want to copy and display as picture at the same time. Is that correct? – Holger Feb 09 '16 at 08:59
  • I don't understand why you think giving the context is irrelevant. Please feel free to point out how I should edit the question to make it easier to understand. To answer your question, yes, I want to copy the JPGs to the hard drive and display the picture but not in that order. – Marcelo Ruiz Feb 09 '16 at 20:29
  • Late answer, but recent Lua hooks could upload/post the image to the display+storage server on image write ( which could be faster if using ftp ) – dvhh May 24 '16 at 02:04

0 Answers0