简体   繁体   中英

Can't use opencv-python in pycharm venv

I'm trying to find a specific image using PyAutoGUI and it works just fine but I can't seem to be able to use 'confidence', 'grayscale' or other OpenCV provided keywords with it. I've tried reimporting the package/library but it still doesn't work. Any idea what could cause this?

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

图片

I cannot post a comment because of low reputation. Why do you think you are unable to use those keywords? It is possible that findmatch.png was generated on a different display. In that case, locateOnScreen will not be able to find the image even when you decrease the confidence because the sizes of the template (findmatch.png) and the portion of the screen you are trying to locate do not match. You will need multiscale template matching if that is the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM