簡體   English   中英

不能在 pycharm venv 中使用 opencv-python

[英]Can't use opencv-python in pycharm venv

我正在嘗試使用 PyAutoGUI 查找特定圖像,它工作得很好,但我似乎無法使用“信心”、“灰度”或其他 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

圖片

由於聲譽低,我無法發表評論。 為什么您認為您無法使用這些關鍵字? findmatch.png 可能是在不同的顯示器上生成的。 在這種情況下,即使您降低置信度,locateOnScreen 也無法找到圖像,因為模板 (findmatch.png) 的大小與您嘗試定位的屏幕部分不匹配。 如果這是問題,您將需要多尺度模板匹配。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM