0

enter image description hereI need to confirm the synchronisation between two mobile users, I would like to do it the following: the first user draws some pattern on the screen (draw something concrete like a house or just some abstract lines) and the other user has to draw the same.

Of course the resulting drawing/base64 will never be the same, but how can I do a comparison to get an idea of how similar the two patterns are?

Example: confirm that the upper and lower drawing are the same

swalkner
  • 16,679
  • 31
  • 123
  • 210
  • Why other user has to draw it? Won't it be easier to make a photo from someone's screen? – Eugene Dudnyk Sep 01 '20 at 23:55
  • I very detailed explanation has been given in this thread - https://stackoverflow.com/questions/23931/algorithm-to-compare-two-images You can use 'edge detection' for approximate comparison of two images. – abhijat_saxena Sep 02 '20 at 17:22

2 Answers2

3

This is quite big what you're trying to do for a so question I think but here's some points I would determine to start working on such a thing:

You will have to determine many parameters to similarity like for example:

  1. How much can 2 lines drift from one another (like in the w you drew, the last stroke is a bit wider, so whats too wide)
  2. Does size matter ? Are w and W the same ?
  3. Does the place of the drawing matters ? Does w in top left corner and w in bottom right corner constitute a similar image ? How much distance is allowed between two similar drawings.
  4. How much difference is allowed, is ABCDEFGHI similar to ABCDEFGH
  5. Does the opasity matters ? Is hello the same as hello ? Seems like from your drawing you're assuming hello is similar to hello.
  6. Does the shape matters ? Is hello in vertical similar to hello in horizontal ?

I would have an approach with these steps:

  1. Identify a start to the 2 drawings (maybe start from an extreme left and identify one or multiple independent drawings e.g. many little circles thrown around)
  2. Move accordingly and keep an entity representing the difference between the two drawings with the points mentioned above.

Your core work is the move and comparing engine, the comparaison is on the part of the drawing on same "direction". This could present an issue when comparing circular shapes. But you can switch what you compare when the change of direction is higher than a certain degree (like more than 30 degrees would take you out of that shape and move to compare next one).

Also gotta think on the situation where there are multiple exits routes to the drawing, so you ll have to start another compare thread and at the same time keep an entity representing what was already passed through to not go into an infinite loop.

So morale of the story, this is big and there's no straight forward easy api to do that for you :).

Ali Ben Zarrouk
  • 1,891
  • 16
  • 24
0

From my side, I think you have two methods to go with. The first one as @Ali said in his answer, handling a lot of parameters, cases and a lot of unexpected things!

Second method, which I prefer.

You said:

I need to confirm the synchronisation between two mobile users

I can guess you have a backend side for this app and by passing current image to the backend and process it using tool/library like Open CV to compare two images and measure the similarities. So the application is getting back a result like 96% similarity.

Lastly, I think this question is too broad!

shim
  • 9,289
  • 12
  • 69
  • 108
Ibrahim Ali
  • 1,237
  • 9
  • 20