Search code examples
c#image-comparisonscreensharingdesktop-sharing

Find the differences between two images for screen sharing apps


Hi I'm writing a client/server remote viewer (desktop sharing) application where screenshots of the desktop are sent across the network over a socket. I'd like to reduce the size of the transfer by getting the difference between the two images and then sending the difference. on the other hand difference will be merge with previous image at other end.

so anyone please guide me how could i accomplish this job. still now i send every time a complete image of the screen over the network programatically and program at other end just show that image. i feel huge data is getting pass over the network and screen update rate at the other end is slow. so please show me good way how to compare between two images and send only difference to other end. also tell me how to merge the difference with actual image at other end.

1) lots of free code and library is available for image comparison but i just do not understand which one i should use and which one would very faster for comparison. so just guide me regarding this.

2) and the most important part is how to send difference only over the network and merge the difference with actual image at other end

i tried lot to get some info regarding my point 2 but got nothing similar. no article i found who can guide me that how to send difference only over the network and merge the difference with actual image at other end

so i am looking for in-depth discussion for my point 2 specially. thanks


Solution

  • You will have to follow three steps:

    1. Create a difference (DIFF) of the two consecutive images. Comparing the two images pixel per pixel will be very time consuming. You should utilize a well-established library like OpenCV; check out the Emgu CV library (http://www.emgu.com/) for .NET: AbsDiff() should be the method you're looking for. The result will be something like DIFF = IMG2 - IMG1.
    2. Send the DIFF through the network. It's still a full image, but JPEG or PNG will utilize its full compression capability assuming it is a mainly black image, i.e. few changes. So these are actually three substeps: Compress - Send - Decompress.
    3. Apply the DIFF on the present image. The recipient can calculate the next image IMG2 = DIFF + IMG1. This can be performed using EmguCV's Add method.