Image Recognition: Hop robot and Image Recognition Robot
Preparation
IDE:VisualStudio
Language:VB.NET/C#
GitHub:AutoJump.NET
This article will introduce you to a method for achieving a "Hop" robot through image recognition.
Section 1 Image Recognition
All the methods and steps mentioned in this article only involve simple vector calculation.
What computing is required?
Compare the pixel color
Center of Vector Set
Calculate the similarity of colors
An RGB color can be considered as a three-dimensional vector.
Comparing the similarity between two colors, we can calculate their Euclidean distance.
You can also directly compare their angle: the smaller the angle, the more similar the two colors, and vice versa.
Returns the center of a vector set.
First, add all the vectors in the set to obtain the vector.S
Then convert the VectorSDivided by the number of elements in the Set, the result is their center
Figure 1-1 recognition effect Preview
Section 2 identifying points
The premise of finding the box point is to discover the common characteristics of each box.
Box features
There are two types of target points: diamond or circular boxes.
Only the top color of some boxes is a large area of solid color.
The background at the bottom of the box is solid, but the color changes as the game starts.
Vertex features
The top side of the vertex is the background color.
The left side of the vertex (may not apply to the circle) and right side (may not apply to the circle) are the background color.
Identification Method
Scan pixels from top to bottom to find the box's verticesA
Continue to findASet of all pixels with similar colorsC
FindCThe center point of the pixel set, that is, the point
Figure 2-1 box position Recognition
Section 3 identifying roles
The color of the role is relatively special and can be easily distinguished from the Game image.
Character features
The role is a chess pawn.
The overall color of the role is consistent, with highlights in some areas.
Vertex features
The role's vertices are darker in color and easy to differentiate
Identification Method
Scan pixels from top to bottom to find the role's verticesA
Continue to findASet of all pixels with similar colorsC
FindCThe center point of the pixel set, and the fixed value is offset downward.
Pixel after center offsetDIs the bottom of the role.
Figure 3-1 role bottom Recognition
Section 4 identify interference
Generally, a simple method is only applicable to the vast majority of cases, and errors will occur in specific situations.
Identification Errors
When the color on the top of the box is inconsistent
When the top position of the role is higher than the target box
When the color of the box standing by the role is the same as that of the top of the target box
Solutions for other interference factors
Extra-score Animation: latency Solution
Hit center Animation: latency Solution
Music symbol animation in the music box: Do not stay on the music box.
Figure 4-1 cube (correct)
Figure 4-2 store (deviation Center)
Figure 4-3 music box (deviation Center)
Section 5 measured values
Some program parameters must be obtained through actual tests.
Recognition Area
Image Recognition is required only for the 1/3 area in the middle of the screen
Touch time
The number of milliseconds on the touch screen is exactly twice the distance between the role and the drop point.
If the distance is 500 pixels, You need to press 1000 milliseconds
This ratio applies to devices with a resolution of 1280*720. Different devices may need to be adjusted properly.
How to calculate otherDeviceResolutionProportion
Calculation formula: Ratio = 2560/device screen height
For example, for devices with a resolution of 1980*1080, the ratio is 2560/1980 = 1.29.
Figure 5-1 Recognition area (Shadow)
Appendix
When we are lucky, robots can play at 1000 points automatically.
GitHub: AutoJump. NET
Reference:. NET is used to develop a one-hop Helper Program.
Reference books: the beauty of mathematics [us] Wu Jun published by People's post and telecommunications Publishing House