[英]Python Pillow image quality different in linux
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;
在Windows中,我的机器人工作正常; however, my bot does not work in Ubuntu.
但是,我的机器人在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.
它不起作用,因为Ubuntu上的屏幕截图图像质量不同,并且它无法进行逐像素匹配。
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. 从Windows运行的工作针和干草堆图像在Ubuntu上工作正常,反之亦然 - 从Ubuntu创建的非工作针和干草堆图像集在Windows和Ubuntu上都不起作用。
My screenshot is always ~6KB in Windows and ~5KB in Ubuntu. 我的截图在Windows中总是大约6KB,在Ubuntu中大约是5KB。
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. 当我在PIL中打开我的本地“针”图像并保存它时,它从1.7KB变为1.5KB并且因此不起作用。 This is the non 500 line version of the code:
这是代码的非500行版本:
# 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?
为什么linux截图质量较差? Should I install a different version of zlib or just use opencv instead?
我应该安装不同版本的zlib还是仅使用opencv?
不同的浏览器(可能还有操作系统/窗口管理器)以不同的方式实现颜色渲染 - 因此显示的像素值可能具有不同的R,G,B值强度,这些值对于人眼是不可见的,但是它们之间的屏幕截图进行跨平台像素比较。浏览器/平台无效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.