Opencv C++ implementation jump jump

Using opencv and c++ to realize jumping, the principle is as follows:
1-Detect the position of the villain and use the template matching function. matchTemplate
2 - If a small dot can be detected, use the template matching function. matchTemplate
3 - If no dots can be detected, calculate the next object center. The steps are as follows:
① Blur the picture
② Canny perform edge detection
③ Eliminate the detected straight lines around the villain, otherwise it will affect the next step
④ Search from left to right from top to bottom to find the position A of the first white point, Determine the X coordinate of the center
⑤ According to the pixel coordinates detected in the fourth step, find the three RGB components of the 3 pixels down from the A position
⑥ According to the three RGB components detected in the previous step, find the same pixel in the picture , according to the position of the villain, search from different directions to find the Y coordinate of the center.
4- The position of the villain and the coordinates of the object to be jumped are detected, ready to simulate pressing the screen.
5- Screenshot Analysis

Below is the source code with detailed explanations in the code.
https://download.csdn.net/download/mengxiangpeng123/10353268

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324489333&siteId=291194637