Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Image recognition?

Lets say I want to create a script that will identify when an image in a game comes up and then do a specific action depending on the image. I'm trying to figure out how to do this? Any ideas?
Is it a specific image or images could be different ? Like :

- When a red circle appears on the screen, your mouse auto click somewhere

or

- When a dog appears (could be different images of dogs, so need IA), your mouse auto click somewhere
(Aug 11, 2020 01:32 AM)Bastille Wrote:  Is it a specific image or images could be different ? Like :

- When a red circle appears on the screen, your mouse auto click somewhere

or

- When a dog appears (could be different images of dogs, so need IA), your mouse auto click somewhere

It's actually 4 images that never change. So it has one image above them and then makes you click the correct image below.
It's difficult to know without seeing the images.
However there is a similar project below which may help give you some direction.
https://github.com/imneonizer/Chrome-dino-game-bot
Hey there,
If I have helped you or if you just enjoy my posts, please consider donating bitcoin to me 1DpL2kcxuidEsjt2MMN2AYufcVoXbi3v2X

[Image: FtwuQgr.gif]
(Aug 11, 2020 12:26 PM)tux1 Wrote:  It's difficult to know without seeing the images.
However there is a similar project below which may help give you some direction.
https://github.com/imneonizer/Chrome-dino-game-bot

If I need some help do you mind if I message you? I can send a photo of the images and go into more detail.
(Aug 11, 2020 12:46 PM)Crypt Wrote:  If I need some help do you mind if I message you?  I can send a photo of the images and go into more detail.

Image recognition isn't my strong point but yes feel free to msg me, I maybe able to point you in the right direction
Hey there,
If I have helped you or if you just enjoy my posts, please consider donating bitcoin to me 1DpL2kcxuidEsjt2MMN2AYufcVoXbi3v2X

[Image: FtwuQgr.gif]
Maybe you can iterate through the RGB values of the image, average them out and see if the value is the same? I'd assume something like that would be different for each image. That's just my guess.
[Image: Iu0EfTL.gif]
(Aug 11, 2020 05:08 PM)Lindros Wrote:  Maybe you can iterate through the RGB values of the image, average them out and see if the value is the same? I'd assume something like that would be different for each image. That's just my guess.

Here just so we are on the same page. It's for a Runescape server.

So it will show you an image like this: https://imgur.com/mSGghN8

Then you have to click the correct image below: https://imgur.com/dkA8Hzw
(Aug 11, 2020 05:12 PM)Crypt Wrote:  Here just so we are on the same page.  It's for a Runescape server.

So it will show you an image like this: https://imgur.com/mSGghN8

Then you have to click the correct image below: https://imgur.com/dkA8Hzw

Do you have access to the actual image file, like could you download it or would you have to screen cap it or something?
[Image: Iu0EfTL.gif]
(Aug 11, 2020 05:13 PM)Lindros Wrote:  Do you have access to the actual image file, like could you download it or would you have to screen cap it or something?

I would have to probably take screenshots and then use the images that way.
(Aug 11, 2020 05:14 PM)Crypt Wrote:  I would have to probably take screenshots and then use the images that way.

Well if you could consistently grab the exact same area, depending on the image format there are libraries I think that you can iterate through the rgb pixel values. I've done stuff like that for school for black and white colorization of images.

I'm not too sure honestly. Maybe look into screen capping specific pixel ranges, than you at least know box 1, 2 or 3 is in each range. Then you can be grabbing the same exact amount of pixels for each box each time. Then you can maybe see if you can analyze the values. Does that make sense? I feel like you would absolutely need to get the exact same image/amount of pixels every time for this method to work.

Honestly i'm really guessing on this, I don't know much about image recognition. That's generally a machine learning technique that is beyond my current level of knowledge.

UPDATE:

What you are looking for is a image classifier. Look into that. You train it by giving it a folder of the images.

It shouldn't be too difficult. I talked to a person I know who knows about machine learning. Try following some tutorials on that.

https://www.pyimagesearch.com/2014/09/15...wo-images/
[Image: Iu0EfTL.gif]
(Aug 11, 2020 05:19 PM)Lindros Wrote:  Well if you could consistently grab the exact same area, depending on the image format there are libraries I think that you can iterate through the rgb pixel values. I've done stuff like that for school for black and white colorization of images.

I'm not too sure honestly. Maybe look into screen capping specific pixel ranges, than you at least know box 1, 2 or 3 is in each range. Then you can be grabbing the same exact amount of pixels for each box each time. Then you can maybe see if you can analyze the values. Does that make sense? I feel like you would absolutely need to get the exact same image/amount of pixels every time for this method to work.

Honestly i'm really guessing on this, I don't know much about image recognition. That's generally a machine learning technique that is beyond my current level of knowledge.

UPDATE:

What you are looking for is a image classifier. Look into that. You train it by giving it a folder of the images.

It shouldn't be too difficult. I talked to a person I know who knows about machine learning. Try following some tutorials on that.

https://www.pyimagesearch.com/2014/09/15...wo-images/

Yeah, I could maybe download all the possible images and somehow sort through them to find the best match?

Also the pixel idea probably won't work because look at this image: https://imgur.com/mSGghN8

They add in those specs of random pixels to through off a possible bot. Which makes it harder.

This is honestly why I chose this program because I knew I'd have to do a lot of research and testing.

This would also probably be a lot easier to do in Java, considering the game is coded in Java and I could use NPC/object Id's.

I want to use Python tho :(
(Aug 11, 2020 05:30 PM)Crypt Wrote:  Yeah, I could maybe download all the possible images and somehow sort through them to find the best match?

Also the pixel idea probably won't work because look at this image: https://imgur.com/mSGghN8

They add in those specs of random pixels to through off a possible bot.  Which makes it harder.

This is honestly why I chose this program because I knew I'd have to do a lot of research and testing.


Are the pixels they add in, in random places every single time?

That seems like a problem for any kind of image recognition. Sorry man don't know too much about it.
[Image: Iu0EfTL.gif]
(Aug 11, 2020 05:35 PM)Lindros Wrote:  Are the pixels they add in, in random places every single time?

That seems like a problem for any kind of image recognition. Sorry man don't know too much about it.

Yeah, most likely every image the pixels will be in a different spot.

However with the link you sent it may not be an issue? It can still look for specific pixel placement? For example different colors or shades of black. I also run into the issue I need the script to recognize when the NPC shows up and to click to talk to him.

I should probably just give up on doing this in Python, it might not make sense to do it in Python.
(Aug 11, 2020 05:42 PM)Crypt Wrote:  Yeah, most likely every image the pixels will be in a different spot.

However with the link you sent it may not be an issue?  It can still look for specific pixel placement?  For example different colors or shades of black.  I also run into the issue I need the script to recognize when the NPC shows up and to click to talk to him.

I should probably just give up on doing this in Python, it might not make sense to do it in Python.

No honestly, if you can do image recognition in any language, Python is the language. Python is probably the number one language for machine learning. You definitely want to train a neural network of some kind to try to categorize the images.
[Image: Iu0EfTL.gif]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by FreddieXxJun 15, 2022 12:46 AM 6 294 Jun 15, 2022 12:46 AM
Last Post: FreddieXx
[.NET] by I cry bloodOct 3, 2020 05:36 AM 6 363 Oct 3, 2020 05:36 AM
Last Post: adelforever4
[C#] by C++Dec 29, 2019 06:16 PM 16 825 Dec 29, 2019 06:16 PM
Last Post: DNA