New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimized searching for specified colors in image_recognition.py with cv::inRange() #106
Conversation
@ComictypX Wow, i did not know that cv2 has such a functions XD. Thank you very much, i will try to test it and give you an feedback |
Tested this. Works really well and fast. Good work thank you. |
Hello, Which file did u edit ? and if u could upload the file would be nice ty . |
Look here: xD |
Can confirm, huge performance improvement. Today we eat oysters for dinner 😎 |
It does not work for me, it throws it, but it catches nothing and does not pull the line. I don’t even know, the code was copied exactly. |
The answer is probably in your comment |
Checked all 10 times, every line, no errors. |
Copy and replace the code from here: If it's not working, dunno |
Yes, I copied from here, there can be no mistakes, but he does not hook or pull anything. ¯_(ツ)_/¯ |
@Logonius are you running your game still in 1080p? What is the bot logging to console? Only "[INFO] Cast fishing rod" ? |
yeah.. i do the same, with the same result, not pulling |
is working for me, i'll do more tests to see, but it really is better |
@ComictypX Can you build and put up in your repository so I can test? |
Works great! |
from reeling at 1/2 when to 1/4 ish |
Is this something that has been added to your updated version or is it something that I need to update manually ? Thank you all for all you smart brains.. can't wait to learn. Python in a couple weeks for a college class 👍 |
@ITgamers If you download it from my "BetterColorSearch" branch it will be included. Otherwise you should use the release in my repo or patch the image_recognition.py manually :) |
Sorry, end of the support. Statement: |
Iterating through a Python array with two nested for-loops is not as fast as openCV/Numpy can do it vectorized.
Therefore, I replaced the two for-loops by the OpenCV function
cv::inRange()
and the python array given by PIL with a numpy one.I tried my best measuring the improvements with measuring the execution time of
call_appropriate_fishing_action()
:Before: ~0,3534 seconds
After: ~0,09526 seconds
== 3,71 times faster (median average bit smaller: 3,62)
Just the color finding part without template matching is ~175 - 200 times faster.
Another Upside: we now have all the color matching pixels and could do some math on them to get the area, e.g. for optimized reeling (all white pixels in mask).