无法使用凸轮保存Basler acA5472-17um相机的照片。开始抓取()



我在保存Basler相机的图像时遇到了麻烦。我想写一个代码,这样我就可以按下" "保存一张图片。代码似乎挂在了cam. retriveresult(2000)上。有什么办法可以解决这个问题吗?

#Code inspiration from: https://github.com/basler/pypylon/blob/master/samples/save_image.py
from pypylon import pylon
import platform
import cv2
count = 0
#path_root = 'C:\Users'
img = pylon.PylonImage()
tlf = pylon.TlFactory.GetInstance()
cam = pylon.InstantCamera(tlf.CreateFirstDevice())
cam.Open()
cam.StartGrabbing()

while True:
with cam.RetrieveResult(2000) as result:
# Calling AttachGrabResultBuffer creates another reference to the
# grab result buffer. This prevents the buffer's reuse for grabbing.
img.AttachGrabResultBuffer(result)
key = cv2.waitKey() & 0xFF
if platform.system() == 'Windows' and key == ord('s'): # press s to safe:
filename = "saved_pypylon_img_%d.png" % count
img.Save(pylon.ImageFileFormat_Png, filename)
print('png image saved')
count += 1
if key == ord('q'):   
break


# In order to make it possible to reuse the grab result for grabbing
# again, we have to release the image (effectively emptying the
# image object).
img.Release()
cam.StopGrabbing()
cam.Close()

您的代码看起来不错,适用于我桌上的相机。这可能是一些配置错误。例如,如果你的相机的触发模式是On,那么你将永远过期,不提供脉冲到相机的输入。

  • 去塔查看器和重置相机默认设置(用户设置控制在用户集选择器:默认用户集>用户设置Load: Execute)

  • 把相机放在连续拍摄,以确保没有错误弹出的消息窗格和相机运行顺利

  • 近镜头&近塔查看器& &;再试一次

最新更新