连接Basler摄像头,并在Pyqt5 GUI上显示视频
我有一个这样的应用程序 1 带有一个显示器以将实时的Basler相机显示在其中。我已经弄清楚了如何连接到巴斯勒相机并在上面显示视频,但是视频不是很顺畅。
#Connect to a camera
for i in MainWindow.camera_db.all():
if True:
info = None
for x in pylon.TlFactory.GetInstance().EnumerateDevices():
if x.GetSerialNumber() == i['id']:
info = x
break
if info is not None:
camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateDevice(info))
camera.Open()
if MainWindow.viewer1 is None:
MainWindow.viewer1 = BaslerOpenCVViewer(camera)
logging.warning(f'Camera 1 - serial number: {i["id"]}-OK')
else:
logging.warning('Camera with {} serial number not found'.format(i['id']))
然后我尝试了
def update_frame(self):
try:
frame = MainWindow.viewer1.get_image()
# frame = cv2.imread('test.jpg')
self.load_display1(frame) # take a frame and show it on MainWindow.display
return frame
except Exception as e:
logging.warning(str(e))
self.time_get_image = QtCore.QTimer(self, interval=1)
self.time_get_image.timeout.connect(self.get_image) #call update_frame function every 1ms to get a real-time video from Basler camera but it's not work well
self.time_get_image.start()
其他方法可以连接到Basler摄像机连续模式并在应用程序上显示。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下代码
从此github获取代码:
You can use the following code
The code is taken from this github:pypylon/samples/opencv.py
创建标签并将IMG发送到显示图像fucnbtion。您将获得图像。
create a label and send the img to displayImage fucnbtion. you will get the image.