#๐Ÿ”’ Pixel color detection

33 messages ยท Page 1 of 1 (latest)

ripe leaf
#

Hello, I need help with a specific place pixel color detection. Like, if its a green pixel, then do something, if its a red pixel, then do something.

proud ravenBOT
#

@ripe leaf

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.

ripe leaf
#

I allow using anything just to simplify the code

naive compass
midnight violet
#

You probably want pyautogui:


im = pyautogui.screenshot()
px = im.getpixel((x, y))
There is a wrapper that lets you get pixel information from a coordinate pair that you can use as well.

px = pyautogui.pixel((x, y)) ```
(Text highlighted from [this StackOverflow post](https://stackoverflow.com/questions/64722136/how-to-use-pyautogui-to-detect-rgb-values)) @ripe leaf
ripe leaf
#

any way to do that?

inland dove
#

Is this realtime on you computer?

ripe leaf
#

yeah

inland dove
#

On you screen, or on your webcam

ripe leaf
#

screen

inland dove
#

And what is the end goal once the pixel colour has been determined

#

what is the output, this will make sense why I am asking once you answer

ripe leaf
inland dove
#

Ah, and is the macro already written in py?

#

if not I would recommend AHK

#

I've done something similar to this before

ripe leaf
#

does it have pixel detection?

#

or actually, what even is that

inland dove
#

its another scripting language, really good for macros

ripe leaf
#

what ide do i use for it?

inland dove
#

I just used notepad++

ripe leaf
#

ight, thanks

inland dove
#

but again, feel free to wait around for someone to tell you how to do this in py. Just throwing in my two cents

ripe leaf
#

it actually seems interesting, ill try ur way

inland dove
#

The only way I can think of how to do it in py is get a screenshot, then use numpy/cv2 to get the colour at a location, that just seems pretty "heavy" to just trigger a macro

ripe leaf
proud ravenBOT
#
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.

#

๐Ÿ”’ Pixel color detection