所以我正在尝试捕捉我屏幕的一部分。但它返回0x0图像。目前我所有的代码都是:
from PIL import ImageGrab
im = ImageGrab.grab(bbox=(466,789,116,439))
print im
>><PIL.Image._ImageCrop image mode=RGB size=0x0 at 0x1E64120>
尽管没有指定bbox
im = ImageGrab.grab()
print im
>><PIL.Image.Image image mode=RGB size=1280x1024 at 0x1F3
我正在尝试制作一个屏幕颜色检测器,所以基本上你可以告诉它你想要找到的颜色的值。但是我遇到的错误是IndexError: image index out of range 我的代码: from PIL import ImageGrab
from win32api import GetSystemMetrics
import numpy as np
def Color(R,G,B):
px = ImageGrab.grab().load()
x = GetSystemMetrics(0)
y = GetSystemMetrics(1)
col
当我将文本值'(255,255,255)‘放在while和if指令中时,而不是位置,一切都很好。我已经对它进行了3个小时的故障排除,我已经没有办法了。我已经确定当颜色相同时,这个循环就会丢失。
我正在制作一个程序,在游戏中使用它,作为我的学校项目。它需要检测你在哪里,我正在通过颜色来检测它,特别是ImageGrab库。
from PIL import ImageGrab
import time
time.sleep(1)
px=ImageGrab.grab().load()
x = 20
y = 20
color = px[x, y]
locat
我目前正在做一个屏幕上的对象查找器,但这是我的代码似乎不能工作,我得到错误AttributeError: 'numpy.ndarray' object has no attribute 'read' 我的对象查找器代码: from PIL import ImageGrab
import cv2
import time
import numpy as np
def find(file):
while True:
Screen = np.array(ImageGrab.grab(bbox=(13, 32,805, 623)))
我做了一个函数,在图像中找到颜色,然后返回x,y。现在我需要添加一个新函数,在这里我可以找到一个具有给定公差的颜色。应该很容易吗?
代码查找图像中的颜色,并返回x,y:
def FindColorIn(r,g,b, xmin, xmax, ymin, ymax):
image = ImageGrab.grab()
for x in range(xmin, xmax):
for y in range(ymin,ymax):
px = image.getpixel((x, y))
if px[0] == r and p
我正在使用PIL中的ImageGrab来获取屏幕上特定像素的RGB值。我很难理解我在哪里设置了x和y坐标来获取像素。以下是目前为止的模式代码: from PIL import ImageGrab
import threading
def getcol():
global pxcolor
threading.Timer(0.5, getcol).start()
pixel=ImageGrab.grab().load()
for y in range(0,1,1):
for x in range(0,1,1):
pxcol
所以基本上,我正在截图我的屏幕,并将格式转换为RGB格式。之后,我有两个for循环来遍历每个像素,并将正确的颜色绘制到像素中。我的程序正在工作,但速度非常慢...有没有办法让它走得更快?
代码如下:
from PIL import ImageGrab
from graphics import *
win = GraphWin('screenshot',1000,1000)
def draw():
for y in range(1000):
for x in range(1000):
r, g, b = rgb_img.get
如前所述,链接:
我的罗技相机将流I420和RGB24与罗技驱动器。
但是,使用Microsoft驱动程序,相机应该会流YUY2和MJPG格式。但我还是得到了RGB24类型的数据。PFB我笔记本电脑里相机司机的快照
I am new to the driver level side and don't know more about drivers .
--我的理解是,--我已经安装了Microsoft驱动程序来安装摄像头,但是相机仍然在流着RGB24类型的原始数据。
我使用Directshow来捕获相机数据。有什么软件/工具可以用来检查来自USB摄像头设备的数据类型吗?
我想从"while标志:~~“循环到代码的末尾,但是当我不放”break“时。只有最后一个"for“短语被重复。我如何重复整个“而旗:~~”部分?我真的是个菜鸟
pyautogui.click(xxx,yyy)
colorlen = len(color)
for i in color:
print(i)
dif = 10
while flag:
pyautogui.moveTo(xxx, yyy)
pyautogui.click(xxx, yyy)
index = index + 1
iter_num += 1
img =
我制作了一个程序来过滤一个只有20种颜色的图像,我想保存程序正在制作的过程,直到它完成,我已经成功地保存了这些图像,但是这需要很长的时间。
假设用户给我一个800x600的图像,我的程序编辑图像需要15秒或更短的时间,但是如果我在每一步之后保存,大约需要10分钟。这是因为每次保存后,程序都在等待文件准备就绪--它不需要它可以移动的图像并让winodws处理它。
我试过用线程来做,我得到了同样的结果,大约每个图像1s。
from PIL import Image
from PIL import ImageGrab
im = Image.open('braw.png') # Ca
我有一个包含876张图片的numpy数组。每个图像的大小为256x256x3。当我打印数组的形状时,我得到(876,),因为我想把它重塑成(876,256,256,3)。 当我尝试使用arrary.reshape(-1,256,256,3)时,我遇到错误,无法重塑(876,)到(876,256,256,3)的数组。 以下是代码片段: for x in trainList:
#print(x[0])
#samples = []
#samples.append(x[0])
name = glob.glob("./"+str(TrainFolder)
在使用Python的PIL的特定区域,如何在屏幕上查找特定像素颜色?
如果某个像素颜色出现在预先指定的区域,我需要一个函数,它将在Python2.7中启动一个命令。我尝试了以下代码,但没有结果:
def game_one():
box = (x_pad+1, y_pad+1, x_pad+1179, y_pad+474)
im = ImageGrab.grab(box)
return im
rgb_im = im.convert('RGB')
for x in range(1055, 1120, 1):
for y in range(20, 464, 1):
所以我的程序是一个速记程序,它将一个图像插入到另一个图像中,我试图在将数据插入封面图像之前对其进行加密。但是,大多数加密模块都需要字符串,我正在尝试传递整数。
我尝试过将字符串转换为字符串然后加密,但是加密过程中充满了特殊的字符和字母,因此不可能将其转换回整数进行插入。
有人知道我能不能加密一个整数吗?不一定要很安全。
我试图在这里添加加密:
for i in range(0,3):
#verify we have reached the end of our hidden file
if count >= len(Stringbits):
#conver
我正在尝试在RGB2010中创建一些内联程序集,以将字节的RGB缓冲区解压到VC++的字节缓冲区中,以下是我的想法:
但是我得到了一个错误
1>c:\users\tom\documents\visual studio 2010\projects\source\engine\image_load.c(28): error C2414: illegal number of operands
1>c:\users\tom\documents\visual studio 2010\projects\source\engine\image_load.c(28): error
我有这样的代码,可以改变卷轴上的背景色,但它只会从“起始颜色”更改为“结束颜色”,它们之间是否可以包含其他颜色?
$(document).ready(function(){
var scroll_pos = 0;
var animation_begin_pos = 0;
var animation_end_pos = $(document).height();
var beginning_color = new $.Color( 'rgb(140,212,208)' );
var ending_color = new $
正如你在代码中看到的,我想创建两个形状,并将它们分组在一起,并使用"for loop“来命名形状,但array()有一个问题,它不接受变量,它将在第一个循环中停止
Sub DRAWSHAPEs()
myDocument = Worksheets(3)
For i = 1 To 10
For j = 11 To 20
With myDocument.Shapes.AddShape(msoShapeRectangle, 100, 150, 50, 70)
.Name = i
.Line.Weight = 4
.Line.ForeColor.RG
我想在我的应用程序中使用imageGrab。我的笔记本电脑是一台装有OSX操作系统的macbook。
当我使用Pillow时,我得到了这个错误:
ImportError: ImageGrab is Windows only
代码:
import ImageGrab
im = PIL.ImageGrab.grab()
但在Pillow文档中写道:
The current version works on OS X and Windows only.
Take a snapshot of the screen.
The pixels inside the bounding box are re