我想编写一个脚本,它可以在屏幕上检测RGB值,然后单击x、y值。我知道如何执行点击操作,但我需要比下面的代码更快地处理图像。Python可以实现吗?
目前,我是一次读取一行,在x = 1920时进入第二行,但处理一行需要大约10秒钟。到那时,屏幕上的人可能已经移动到完全不同的位置,而我只完成了一行!
我能否加速这段代码,或者是否有更好的方法来实现我的目标呢?如果在Python中不可行,我也可以考虑C++选项 :)
import Image
x = 0
y = 0
im = Image.open("C:\Users\sean\Desktop\screen.jpg")
pix = im.load()
print im.size #get width and height of the image for iterating over
while x < 1920:
print pix[x,y] #get RGBA value of the pixel of an image
print "x is:" +str(x)
x = x + 1
print "y is: " +str(y)
if x == 1920:
x = 0
y = y + 1