Basler的python库安装(windows)

Basler官方的python支持放到了GitHub上,GitHub - basler/pypylon: The official python wrapper for the pylon Camera Software Suite

截止到2022.11.27日,支持到python 3.10版本,因此先安装python,再安装pypylon。

1、安装python 3.10

2、下载对应python版本的pypylon

3、安装本地whl文件

cmd中输入安装(我把whl放到了C盘根目录)

【实践】

使用VS新建python项目

 

 具体代码:

from pypylon import pylon

camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
camera.Open()

# demonstrate some feature access
new_width = camera.Width.GetValue() - camera.Width.GetInc()
if new_width >= camera.Width.GetMin():
    camera.Width.SetValue(new_width)

numberOfImagesToGrab = 100
camera.StartGrabbingMax(numberOfImagesToGrab)

while camera.IsGrabbing():
    grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)

    if grabResult.GrabSucceeded():
        # Access the image data.
        print("SizeX: ", grabResult.Width)
        print("SizeY: ", grabResult.Height)
        img = grabResult.Array
        print("Gray value of first pixel: ", img[0, 0])

    grabResult.Release()
camera.Close()

更多案例参考 pypylon/samples at master · basler/pypylon · GitHub

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章