I have a bot that plays an online game that is driven by selenium. It works by utilizing image recognition (finding subimages). In Windows, my bot works fine; however, my bot does not work in Ubuntu.
The bot works like this:
I've traced the issue to the function I'm using to find a subimage. It doesn't work because the screenshot image quality is different on Ubuntu, and it can't do a pixel by pixel match.
A working needle and haystack image set from Windows works fine on Ubuntu, and the inverse is also true -- a non-working needle and haystack image set created from Ubuntu does not work on both Windows and Ubuntu.
My screenshot is always ~6KB in Windows and ~5KB in Ubuntu.
When I open my local "needle" image in PIL and save it, it goes from 1.7KB to 1.5KB and doesn't work as a result. This is the non 500 line version of the code:
# imports and everything else here..
browser.save_screenshot("haystack.png") # selenium screenshot
haystack = Image.open("haystack.png")
needle = Image.open("needle.png") # the needle is a local file
haystack.save("haystack_new.png","PNG",quality=100) # DEBUGGING
needle.save("needle_new.png","PNG",quality=100) # DEBUGGING
# call "needle in a haystack" locator function here
Can someone tell me what's going wrong? Why are the linux screenshots lower quality? Should I install a different version of zlib or just use opencv instead?
不同的浏览器(可能还有操作系统/窗口管理器)以不同的方式实现颜色渲染 - 因此显示的像素值可能具有不同的R,G,B值强度,这些值对于人眼是不可见的,但是它们之间的屏幕截图进行跨平台像素比较。浏览器/平台无效。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.