Machine Learning with League of Legends - Minimap Detection (Part 1)
Links to series
Updates
- This was made back in March 2020 right as COVID hit. After over a year of forgetting to upload this post, I finally uploaded.
Abstract
The minimap is an important feature in the popular online MOBA, League of Legends. Automatic detection of champions icons on the minimap can provide additional information.
Introduction
The minimap in League of Legends is a global view of the state of the game contained in a top down 2D view of the map. The minimap contains information such as the position of the ally champions, positions of enemy champions (if they are visible), visibility covered by wards, what towers and inhibitors are up, etc…
The minimap is an extremely important tool that a player can view to gain more information about the current state of the game.
Champions also appear on the minimap (visually with the champion image as an icon). Detecting champion on the minimap can produce useful information – aiding in helping players visually see enemy champions appear, tracking the movements of professional players, etc. Let’s tackle this problem!
Why not use classical computer vision algorithms?
Detection of champion seems simple enough for an attempt to use classical computer vision algorithms/techniques.
A system that could detect champions on the minimap fairly well was built using OpenCV Library (one of the most popular open-source computer vision library).
So, I attempted to make a detection system using opencv.
The detection is split into two parts; the top image detects champions on the red side and the bottom image detects champions on the blue side.
An high level overview of detection is presented in the following pipeline image:
The first step of the pipeline is to use cv2.inRange to filter out colors belonging to the circle border belonging to champion icons in order to focus on parts of the minimap that could possibly contain a champion.
The next step is to use cv2.findContours to find a curve joining continous points (basically any line of points that are connected). The boundaries of the contours are computed with cv2.minEnclosingCircle and they are checked to ensure that they are at least the size of a champion icon.
Lastly, cv2.matchTemplate is used to find the location of champion icons in the regions found using contours. A threshold is used to ensure that enough of the image matches the champion.
Pitfalls
As one may notice, the system is not perfect; champions are not detected frequently as one would expect and there are sometimes false positive labels.
Some examples include:
Conclusion, future work and moving forward
In the perfect scenario, where there are no overlaying objects (even other champions can overlay another champion partially or fully), the system can still fail to detect certain champions or miscategorize seemingly random parts of the minimap as another champion.
The miscategorization is affected by the threshold. I have not found a perfect threshold to balance finding champions and generating miscategorizations.
Future work include using ORB or SIFT to extract keypoints and find features that match the champion icons, which may improve image detection significantly.
Now that we have an idea of what problems there are, the next post discusses an improved approach in detail.
Enjoy Reading This Article?
Here are some more articles you might like to read next: