【发布时间】:2022-12-05 19:22:20
【问题描述】:
我正在学习pypylon。以下代码是我第一次成功捕获图像并通过 PIL 显示它。一切都很好,但一方面:它正在以灰度模式捕捉,而我希望以彩色模式捕捉。而我需要的信息丢失在浩瀚的文档和类的海洋中。
我可以看到他们提供了无数的颜色格式,我不在乎:我只需要一些颜色并且可以很好地转换为 PIL 图像的东西。有人可以建议对该程序进行小的修改以实现该目标吗? (顺便说一句,2000 参数有什么作用?)
# minimal capture image and show on screen in PIL format
import pypylon.pylon as py
from PIL import Image
tlf = py.TlFactory.GetInstance()
camera = py.InstantCamera(tlf.CreateDevice(devices[0]))
camera.Open()
camera.StartGrabbing(1)
grab = camera.RetrieveResult(2000, py.TimeoutHandling_Return)
if grab.GrabSucceeded():
img = grab.GetArray() # format: numpy array
print(f'Size of image: {img.shape}')
image = Image.fromarray(img)
image.show()
camera.Close()
【问题讨论】:
标签: camera python-imaging-library image-capture