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

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