from pypylon import pylon
import cv2
import numpy as np
class BaslerCameras:
def __init__(self, interface_type, width, height, exposure, gain):
"""
初始化 BaslerCamera 类
:param interface_type: 接口类型 ('GigE' 或 'USB')
:param width: 图像宽度
:param height: 图像高度
:param exposure: 曝光时间(微秒)
:param gain: 增益
"""
self.interface_type = interface_type
self.camera = None
self.width = width
self.height = height
self.exposure = exposure
self.gain = gain
# 初始化 Pylon 系统
# pylon.initialize()
# 获取所有可用的相机
self.camera_list = pylon.TlFactory.GetInstance().EnumerateDevices()
if not self.camera_list:
raise RuntimeError("No camera detected")
# 根据接口类型选择相机
self.select_camera()
# 配置相机参数
self.camera.Width = self.width
self.camera.Height = self.height
self.camera.Exposu
python basler 相机调用方法 USB通信 网口通讯 多台相机同时启用
于 2024-08-10 14:47:25 首次发布