【发布时间】:2015-06-17 07:52:59
【问题描述】:
我正在尝试编写一个脚本来检测屏幕上的 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
【问题讨论】:
-
你可以试试opencv python wrapper?
-
链接:OpenCV
-
“点击 x,y”是什么意思?
标签: python image image-processing rgb