#๐Ÿ”’ opencv error

5 messages ยท Page 1 of 1 (latest)

forest depot
#

im trying to make my code detect an image on the screen

while 1:
    try:

        if pyautogui.locateOnScreen('drillpoint1.png') or pyautogui.locateOnScreen('drillpoint1_mining.png') or pyautogui.locateOnScreen('drillpoint2.png') or pyautogui.locateOnScreen('drillpoint2_mining.png')  is not None:
            print("Yes")
            time.sleep(0.5)
    except pyautogui.ImageNotFoundException:
        print("No")
        time.sleep(0.5)

it always prints no because it does not find the exact image, but when i try adding confidence

while 1:
    try:

        if pyautogui.locateOnScreen('drillpoint1.png', confidence=0.8) or pyautogui.locateOnScreen('drillpoint1_mining.png', confidence=0.8) or pyautogui.locateOnScreen('drillpoint2.png', confidence=0.8) or pyautogui.locateOnScreen('drillpoint2_mining.png', confidence=0.8)  is not None:
            print("Yes")
            time.sleep(0.5)
    except pyautogui.ImageNotFoundException:
        print("No")
        time.sleep(0.5)

i get this error: NotImplementedError: The confidence keyword argument is only available if OpenCV is installed.

So when i try to instal opencv with "pip install opencv-python" i get this error:

error: metadata-generation-failed

ร— Encountered error while generating package metadata.
โ•ฐโ”€> numpy

note: This is an issue with the package mentioned above, not pip."

i dont know how to fix

frank ginkgoBOT
#

@forest depot

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

forest depot
#

also, im using pycharm

frank ginkgoBOT
#

@forest depot

Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.