简体   繁体   English

彩色而非灰度的简单塔架捕获

[英]Simple pypylon capture in color not grayscale

I'm in the process of learning pypylon.我正在学习pypylon。 The following code is my first success at capturing an image and displaying it via PIL.以下代码是我第一次成功捕获图像并通过 PIL 显示它。 All good, but for one thing: it is capturing in grayscale and I would like to be capturing in color.一切都很好,但一方面:它正在以灰度模式捕捉,而我希望以彩色模式捕捉。 And the information I need is lost in the vast sea of documentation and classes.而我需要的信息丢失在浩瀚的文档和类的海洋中。

I can see that they offer zillion color formats, and I don't care: I just need something that is color and will convert nicely to a PIL image.我可以看到他们提供了无数的颜色格式,我不在乎:我只需要一些颜色并且可以很好地转换为 PIL 图像的东西。 Can someone suggest a small modification to this program that would accomplish that?有人可以建议对该程序进行小的修改以实现该目标吗? (And by the way, what does the 2000 parameter do?) (顺便说一句,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()

You should look at the following website: https://docs.baslerweb.com/pixel-format You need to use the command: camera.PixelFormat.SetValue(PixelFormat_BGR8);您应该查看以下网站: https://docs.baslerweb.com/pixel-format您需要使用命令: camera.PixelFormat.SetValue(PixelFormat_BGR8);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM