Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

BufferedImage Comparisons

If I have 2 sequential screenshots stored as BufferedImages, is it possible to compare them to get the differences.  I'd like to take the differences and send them over a socket to a server and be able to reconstitute the image on the fly.  Essentially I'd only be transmitting image changes so that i can achieve a more efficient "stream".  On the server side, i would accept the differences and apply them to the current image.

1) send initial image from client to server
2) client takes new picture and compares with previous
3) image differences are sent to server
4) server takes differences and applies to previous image

I hope that my question is clear.  What type of data storage object would be efficient for thsi?  Just a simple array as is used as the data backing of a BufferedImage?

Thanks,
David
0
lomidien
Asked:
lomidien
1 Solution
 
CEHJCommented:
0
 
aozarovCommented:
on the server you can get the current and previous BufferedImage pixels by calling their getRGB method.
then you can compare one to the other an populating a new array (the same length) by putting the delta of the two (hopefully many will be zero).
Then you can run some compression on that (like Run length encoding or similar) and send it to the other side which will decompress it and add the deltas array to its current buffer.
I advice you to send the full image from time to time (every X frames) as a correction mechanisim (TV broadcasting does it as well).
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now