阿尔比恩(Albion Online)钓鱼脚本

发布时间: 2021-06-15

尝试制作一个用于钓鱼脚本,关于阿尔比恩的钓鱼脚本,问题是在这个游戏中指针非常细,并且有许多不同的纹理和颜色,可以进行简单的灰度匹配在滑块的一个部分(例如,水纹理)上效果很好,有时在其他部分(树纹理)上效果,而在第三个元素上效果不佳。如果我更改为较低的阈值,它将经常激活而没有匹配。

# import the necessary packages
from collections import deque
from imutils.video import VideoStream
import numpy as np
import argparse
import cv2
import imutils
import time
from mss.linux import MSS as mss
from PIL import Image
import mss
import numpy
import pyautogui
# construct the argument parse and parse the arguments
ap = argparse.ArgumentParser()
ap.add_argument("-v", "--video",
    help="path to the (optional) video file")
ap.add_argument("-b", "--buffer", type=int, default=64,
    help="max buffer size")
args = vars(ap.parse_args())
# define the lower and upper boundaries of the "green"
# ball in the HSV color space, then initialize the
# list of tracked points
greenLower = (42, 84, 211)
greenUpper = (69, 130, 255)
blueLower = (88, 76, 255)
blueUpper = (151, 76, 255)
pts = deque(maxlen=args["buffer"])

# grab video from screen(monitor area)
with mss.mss() as sct:
    monitor = {"top": 325, "left": 4423, "width": 136, "height": 662}
    while "Screen capturing":
        #last_time = time.time()
        #vs = numpy.array(sct.grab(monitor))
        #print("fps: {}".format(1 / (time.time() - last_time)))
        vs = sct.grab(monitor)
        # grab the current frame
        #frame = vs
        frame = np.array(vs)
        # resize the frame, blur it, and convert it to the HSV
        # color space
        blurred = cv2.GaussianBlur(frame, (11, 11), 0)
        hsv = cv2.cvtColor(blurred, cv2.COLOR_BGR2HSV)
        # construct a mask for the color "green", then perform
        # a series of dilations and erosions to remove any small
        # blobs left in the mask
        mask = cv2.inRange(hsv, greenLower, greenUpper)
        mask = cv2.erode(mask, None, iterations=2)
        mask = cv2.dilate(mask, None, iterations=2)
        mask2 = cv2.inRange(hsv, blueLower, blueUpper)
        mask2 = cv2.erode(mask2, None, iterations=2)
        mask2 = cv2.dilate(mask2, None, iterations=2)
        # find contours in the mask and initialize the current
        # (x, y) center of the ball
        cnts = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
        cnts = imutils.grab_contours(cnts)
        center = None
        cnts2 = cv2.findContours(mask2.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
        cnts2 = imutils.grab_contours(cnts2)
        center2 = None
        # only proceed if at least one contour was found
        if len(cnts) > 0:
            # find the largest contour in the mask, then use
            # it to compute the minimum enclosing rectangle and
            # centroid
            c = max(cnts, key=cv2.contourArea)
            (x, y, w, h) = cv2.boundingRect(c)
            M = cv2.moments(c)
            center = (int(M["m10"] / M["m00"]), int(M["m01"] / M["m00"]))
            c2 = max(cnts2, key=cv2.contourArea)
            (x2, y2, w2, h2) = cv2.boundingRect(c2)
            M2 = cv2.moments(c2)
            center2 = (int(M2["m10"] / M2["m00"]), int(M2["m01"] / M2["m00"]))
            # draw the rectangle and centroid on the frame,
            # then update the list of tracked points
            cv2.rectangle(frame, (int(x), int(y)), (int(x+w), int(y+h)),(0, 255, 255), 2)
            cv2.circle(frame, center, 5, (0, 0, 255), -1)
            cv2.rectangle(frame, (int(x2), int(y2)), (int(x2+w2), int(y2+h2)),(0, 255, 255), 2)
            cv2.circle(frame, center2, 5, (0, 0, 255), -1)
            # update the points queue
            pts.appendleft(center)
            if y-15 < y2 < y+15:
                pyautogui.click(4908, 984)
                time.sleep(2)
                y2 = 0           
        cv2.imshow("frame", frame)
        key = cv2.waitKey(1)
        if cv2.waitKey(25) & 0xFF == ord("q"):
            cv2.destroyAllWindows()
            break

 

  1. iauw
    2022-03-30 12:09:30

    这能用?代码最后一行括号都没对齐的

  2. 123
    2021-11-20 10:07:00

    用python

  3. 快乐的冬
    2106-02-07 14:28:15

    兄弟?

  4. 快乐的冬
    2106-02-07 14:28:15

    这个用什么运行?

请在下方留下您的评论.加入TG吹水群