홈페이지 »
미니맵으로 인식
메랜은 미니맵으로 실시간 캐릭터 위치를 볼수 있다.
미니맵으로 캐릭터 좌표인식해서 작동하는법
미니맵사진

import cv2
import numpy as np
image = cv2.imread('minimap1.png')
hsv_image = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
#yellow point 세팅
lower_yellow = np.array([20, 180, 180])
upper_yellow = np.array([30, 255, 255])
mask = cv2.inRange(hsv_image, lower_yellow, upper_yellow)
#yellow point 찾기
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
target_color = np.array([25, 255, 255])
min_distance = float('inf')
best_contour = None
best_center = None
for contour in contours:
shape_mask = np.zeros_like(mask)
cv2.drawContours(shape_mask, [contour], -1, 255, thickness=cv2.FILLED)
mean_color = cv2.mean(hsv_image, mask=shape_mask)[:3]
distance = np.linalg.norm(mean_color - target_color)
if distance < min_distance:
min_distance = distance
best_contour = contour
M = cv2.moments(contour)
if M["m00"] != 0:
cX = int(M["m10"] / M["m00"])
cY = int(M["m01"] / M["m00"])
best_center = (cX, cY)
if best_contour is not None:
cv2.drawContours(image, [best_contour], -1, (0, 255, 0), 2)
cv2.circle(image, best_center, 5, (0, 0, 255), -1)
#yellow point 보여주기
cv2.imshow('Closest Yellow Shape', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
미니맵 인식 결과
