I have an application that takes a gallery of pictures (all in Jpeg) and give similarity scores between each possible pairs. At every point in time, only one pair can be selected and its similarity score is displayed.
The algorithm that compare the two images has a certain performance cost, such that it takes a few seconds to compare a pair.
When two pictures are selected:
- If the pair has never been compared, the score shows "Not scored yet.". The user can click the "Score" button and the pair will be sent to a thread that queues scores to be computed. Example: http://db.tt/gb1Yk6yx
- If the pair is currently in the queue to be computed, the score field shows "Computing...". Example: http://db.tt/OvS1qGP3
- If the pair has been compared, the score attached to the pair is shown. Example: http://db.tt/m2OQGybW
Example (when doing a batch): http://db.tt/iD67SdCp
If a score has never been computed, and a user click "Score", the field will switch to "Computing..." then will display the score when the computation is completed.
Before displaying anything in the field of the score, when two pairs are selected, their attached Bitmap are sent to a HashMap that verify if those two Bitmaps already have an attached score, in which case it simply return it. If there's no score, then the job is sent in the queue.
To know if the score exists in the cache, I need to find a way to hash the pair so that I can use the resulting key to lookup the cache. That's where my problem is. To make sense, the hashing of the two Bitmap should be fast. Otherwise, I'm just adding another layer of computation. But, the way I do so far to hash the two Bitmap is to send them in a byte array and get the