【问题标题】:Can't use opencv-python in pycharm venv无法在 pycharm venv 中使用 opencv-python
【发布时间】:2021-06-04 23:44:16
【问题描述】:

我正在尝试使用 PyAutoGUI 查找特定图像,它工作得很好,但我似乎无法使用 'confidence'、'grayscale' 或其他 OpenCV 提供的关键字。我试过重新导入包/库,但它仍然不起作用。知道是什么原因造成的吗?

import pygetwindow as gw
import pyautogui as ag
import cv2

lol = gw.getWindowsWithTitle('League Of Legends')[0]
r = 0
while True:
    try:
        while r == 0:
            if lol.isActive:
                print("lol is active")
                ag.locateOnScreen('findmatch.png', confidence=.9)
                ag.click('findmatch.png')
        break
    except:
        r = 1
        print("Image not found")
    break

【问题讨论】:

    标签: python opencv pyautogui


    【解决方案1】:

    由于声誉低,我无法发表评论。为什么您认为您无法使用这些关键字? findmatch.png 可能是在不同的显示器上生成的。在这种情况下,即使您降低置信度,locateOnScreen 也无法找到图像,因为模板 (findmatch.png) 的大小与您尝试定位的屏幕部分不匹配。如果这是问题,您将需要多尺度模板匹配。

    【讨论】:

      猜你喜欢
      • 2021-03-11
      • 2021-11-29
      • 2019-07-07
      • 2021-04-29
      • 2019-04-09
      • 1970-01-01
      • 2019-11-09
      • 2020-06-13
      • 1970-01-01
      相关资源
      最近更新 更多