Clash of Clans screen image processing

asked 2016-01-31 14:46:56 -0500

Riko gravatar image

I am turning to you with a question on image processing of Clash of Clans screen image.

I want to process screen in Clash of Clans. More precisely I want to locate all building in the image. Here is a sample image (main image) of Clash of Clans village below:

CoC sample image

In the above image I would use template images to find positions of buildings. For example, following picture (template image) would be used to detect town hall: enter image description here

We can see that position of template image on the main image is under the wall surrounded with three fire camps. We would like to have an algorithm that returns coordinates of template image or multiple coordinates if there are several such building in the main image. We will repeat this process to obtain a full state of the screen.

Here are some conditions:

  • template image might be only partially seen on the main image (looking at main image above several building in the village are only partially seen or covered with walls, workers etc.)

  • main image might have a poor resolution (the above resolution of image of village is a good sample, but resolution might be even worse)

  • we can provide highly detailed images of building as seen above

  • we want a highly reliable algorithm (something like 95%+ reliable)

To solve the above problem I am currently planning to use some sort of fuzzy template matching algorithm in openCV (using Python, Java or C++), however I am not sure what the best approach to resolve such a problem is.

Looking for guidance and possibly some sample code in Python, Java or C++!

Thank you for your help!

edit retag flag offensive close merge delete

Comments

3

Did you try the matchTemplate function?

(hint: it might be exactly what you are looking for :) )

kbarni gravatar imagekbarni ( 2016-02-01 02:51:15 -0500 )edit

I have tried matchTemplate and it actually works very well for the above example. However I couldn't match walls or gold storages with it.

Riko gravatar imageRiko ( 2016-02-01 03:05:26 -0500 )edit
1

I don't know clash of clans (so no idea what's a gold storage), but you are already on the right way.

If your method won't work for a few type of structures, just create some special methods to detect them. If those gold storages are yellow, you can segment this color on a HSV image.

To detect linear structures like walls, you can use the HoughLinesP function.

Detecting the "squares" on the "board" might help to make the detection more robust.

kbarni gravatar imagekbarni ( 2016-02-01 03:37:42 -0500 )edit