drov0 / python-imagesearch

A wrapper around opencv2 and pyautogui to do image searching easily.
MIT License
280 stars 99 forks source link

libpng warning: sBIT: invalid #15

Closed chriswelde closed 4 years ago

chriswelde commented 4 years ago

Hello,

I'm trying to use this library to automate a game. I've taken a screenshot of the game with Print Screen on Windows 10, opened it in Paint, cropped the thing I want to identify later on when I'm trying to automate the game, added it to my Python project workspace.

But when I try to sanity check things and by first attempting to find the image while the game is running, the console repeatedly prints out "libpng warning: sBIT: invalid" What I'm trying to find: brgsoda

What the screen looks like as a whole: ss1

I'm only searching the upper half of the screen, where the chat bubbles appear. the code: pos = imagesearch_region_loop("./brgsoda.png", 0.5, 0, 0 , 1100 ,350) if pos[0] != -1: print("position : ", pos[0], pos[1]) pyautogui.moveTo(pos[0], pos[1]) exit(0) else: print("image not found")

chriswelde commented 4 years ago

Nevermind, paint wasn't converting the cropped pictures to truly a .png.

But even after fixing that, it still won't find the burger + soda when the game is running and the customer is asking for it. Any tips on how you'd approach automating this game?

You can kind of see what the goal of the game is, the customer gives an order combination, you click what he wants on the white screen to the left and press the done button (not shown), if it's right, you get money.

drov0 commented 4 years ago

Oh ! Sorry I missed that issue.

That's kind of an issue with 3d games, images and icon may appear closer or farther changing their shape completely (a 30x30 image is very different from a 60x60 image for pythonimagesearch)

Tbh I would just go overkill and train a small neural net to recognize the items.