How to locate an object on a screenshot using Python, OpenCV & PyAutoGUI

How to locate one or many objects on a given screenshot with python, opencv and pyautogui using pattern detection.
Source code:
github.com/maksimKorzh/open-c...
Support the channel:
/ code_monkey_king

Пікірлер: 38

  • @storyks
    @storyks2 жыл бұрын

    thanks for the knowledge You teach very easy to understand.

  • @naveenvarmaa
    @naveenvarmaa3 жыл бұрын

    Very Informative

  • @robr9313
    @robr93132 жыл бұрын

    Thank you, solved all my issues.

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    2 жыл бұрын

    Great)

  • @python360
    @python3603 жыл бұрын

    This is fantastic man. This is a great evolution from web scraping. I had to work out how to extract text from a video, but getting an image from a video is very cool. This could have many ML implementations as well?

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    3 жыл бұрын

    Yup, sure and extracting text should be easy as well if it's not a handwriting. I believe that potentially it can be done using template matching from built-in opencv functions)

  • @user-ke9le9dj8r
    @user-ke9le9dj8r2 жыл бұрын

    It's fine, thanks!

  • @am-kl2lg
    @am-kl2lg2 жыл бұрын

    Hi, did you tryed useing this software on a different monitor with another screen scale? I'm haveing some problems when i switch from laptop monitor to external monitor

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    2 жыл бұрын

    It needs to be initialized on every new monitor because it relies on the absolute coordinates.

  • @pranayasinangwidhi9840
    @pranayasinangwidhi984011 ай бұрын

    Can you help me? I made pretty much the same thing. Mine screenshot the detected image (or rather take a full screenshot and then cut the detected part) I used confidence 0.65 and it works well. But everytime there is a slight difference to the detected object, it either doesn't detect or doesn't detect well. I am trying to use AI for the detection. but I don't know how. Can you help me?

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    11 ай бұрын

    I'd love to but I don't know how because just adjusting confidence was fairly enough for my needs.

  • @W-meme
    @W-meme2 жыл бұрын

    How to use x and y separately in locate on screen. EDIT: Got it you explained in the video. Thanks a lot.

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    2 жыл бұрын

    Cool) Feel free to inspect my chess programming channel if you're interested: kzread.info/dron/B9-prLkPwgvlKKqDgXhsMQ.html

  • @W-meme

    @W-meme

    2 жыл бұрын

    @@monkey_see_monkey_do please help error cannot unpack non iterable numpy.int64 object

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    2 жыл бұрын

    @@W-meme are you running my code? Or how are you getting this error? This tutorial is intended to follow step by step in order to come up with the pattern recognition so if you just grab the code and try to run it then it shouldn't work because of relying on the EXACT screenshot. In your environment you probably have it slightly different hence it's not working. It's only a guess though. So you just try to follow step by step and if the error occurs descibe it in MORE details because without having an idea of what exactly you're doing it's hard to figure out what's going wrong.

  • @W-meme

    @W-meme

    2 жыл бұрын

    @@monkey_see_monkey_do thanks for replying, I'm assigning variables the values of these points because I'm cropping from multiple locateonscreen bpundaries. Somehow running for loop and using locateonscreen as array works. Assigning x and y bound.left and bound.right .

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    2 жыл бұрын

    @@W-meme I would've sptitted image into parts and then processed it part by part. You just try to locate object on one image first and when it works go for next image.

  • @errorgradov8050
    @errorgradov8050 Жыл бұрын

    Bro i got problem ,when i try to print the width of object it says "'Point' object doesn't have attribute 'width'" could you please help me?

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    Жыл бұрын

    Check out the docs, I don't remember by heart.

  • @EscoladoDiaaDia
    @EscoladoDiaaDia Жыл бұрын

    Excellent video! I would like to know how you can click on a specific pawn and move it. How to differentiate it from others? Thank you very much

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    Жыл бұрын

    Squares are referenced as the absolute ranges of coordinates.

  • @nahuelastor7522
    @nahuelastor7522 Жыл бұрын

    I have that problem. When I install OpenCV python stop working in all my proyects. So I have to uninstall python, delete the folders and re-install python

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    Жыл бұрын

    Are you on windows? if so I can't help.

  • @mrsnappy9977
    @mrsnappy99772 жыл бұрын

    i am trying to do the same thing but not from a ss but from a file and using cv2.imread instead of pyautogui.screenshot does not seem to work.Can anyone help me?

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    2 жыл бұрын

    Check out image encoding. When you do screenshot you need additional conversions, with file read open v already opens a file in a preferred representation.

  • @mrsnappy9977

    @mrsnappy9977

    2 жыл бұрын

    @@monkey_see_monkey_do Ok i will check that out. Thanks!

  • @MrWafflero

    @MrWafflero

    Жыл бұрын

    do you have an update ? im having the same issue

  • @gambarimas

    @gambarimas

    Жыл бұрын

    I think you can find a way in this video kzread.info/dash/bejne/qIylrdCihsicgJs.html

  • @MrSanman28
    @MrSanman28 Жыл бұрын

    Can the found objects be kept and remove everything else?

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    Жыл бұрын

    Yes

  • @MrSanman28

    @MrSanman28

    Жыл бұрын

    @@monkey_see_monkey_do do you have a video on how to?

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    Жыл бұрын

    @@MrSanman28 no, you can use the code to draw red rectangle to capture the desired part of the image to store it, then remove the initial picture, or even don't - just write the desired part into file.

  • @poornimavemula67
    @poornimavemula672 жыл бұрын

    Can u send me the code for finding missing objects in an image

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    2 жыл бұрын

    sorry, I didn't get what you mean

  • @theboss4ever99
    @theboss4ever992 жыл бұрын

    This is a really nice implementation, Kindly help me extract the images of chess puzzles from pdf and then turn them into chess fen and then chess diagram.

  • @monkey_see_monkey_do

    @monkey_see_monkey_do

    2 жыл бұрын

    Glad it helps. I have a chess programming dedicated channel: kzread.info/dron/B9-prLkPwgvlKKqDgXhsMQ.html maybe you'll get interested.

  • @theboss4ever99

    @theboss4ever99

    2 жыл бұрын

    @@monkey_see_monkey_do.. I have seen few of them, I want 2 know the specific which I mentioned above. If u relate any video would that It will be really great help for me.

  • @user-ic7tz2se9l
    @user-ic7tz2se9l Жыл бұрын

    обнял