【问题标题】:Simple pypylon capture in color not grayscale彩色而非灰度的简单塔架捕获
【发布时间】: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


    【解决方案1】:

    你应该看看下面的网站:https://docs.baslerweb.com/pixel-format 你需要使用命令: camera.PixelFormat.SetValue(PixelFormat_BGR8);

    【讨论】:

      猜你喜欢
      • 2020-03-21
      • 1970-01-01
      • 2021-10-06
      • 2015-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-28
      相关资源
      最近更新 更多