#๐Ÿ”’ Image Recognition

20 messages ยท Page 1 of 1 (latest)

cold gust
#

Hello, so i had a friend write some code for me that ive never done before. Im trying to mess with image recognition but im not too sure whats wrong with this code. My goal is to use to detect a reference image before moving on to the next part of the code. This is what i have as of now. And here is my error included.

wispy cypressBOT
#

@cold gust

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.

cold gust
desert holly
#

Put r before the string to let python know it should take it as-is, without trying to interpret backslashes as escape commands.

Also, one set of quotes only.

So like image_path = r"C:\Users..."

cold gust
#

Gotcha will try the r now

#

and yeah i noticed the quotes after i sent this!

#

This is the error i got.

#

@desert holly so it worked partly i think but im not sure what im looking at

#

im assuming since it has retries it failed to find the image on screen with the ammount of retries?

signal wyvern
desert holly
#

You did if/else but it seems the function raises an exception if image is not found instead of returning something falsy. So you need try/except instead of if/else

cold gust
#

Ok, yeah i had a friend write is at ive never messed with if statements or image recognition so this is my frist time.

#

is there a reason why it culdnt find a image tho? if the image is on my screen?

desert holly
desert holly
cold gust
#

So im using a screenshot i had taken from a larger screen. The part that i took a screenshot is fully visable.

#

ok ill see

wispy cypressBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.