1
This commit is contained in:
37
andor-test/02_snap_and_display.py
Normal file
37
andor-test/02_snap_and_display.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from pylablib.devices.Andor import AndorSDK3Camera
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# 连接相机
|
||||
cam = AndorSDK3Camera(idx=0)
|
||||
cam.open()
|
||||
print("已连接到相机")
|
||||
|
||||
# 设置采集模式
|
||||
cam.setup_acquisition(mode="snap", nframes=1)
|
||||
print("设置采集模式: snap, 1帧")
|
||||
|
||||
# 开始采集
|
||||
cam.start_acquisition()
|
||||
print("开始采集")
|
||||
|
||||
# 等待并读取图像
|
||||
cam.wait_for_frame()
|
||||
frames = cam.read_multiple_images()
|
||||
print(f"读取到 {len(frames)} 帧图像")
|
||||
|
||||
# 停止采集
|
||||
cam.stop_acquisition()
|
||||
print("停止采集")
|
||||
|
||||
# 显示图像
|
||||
image = frames[0]
|
||||
print(f"图像尺寸: {image.shape}")
|
||||
plt.figure(figsize=(10, 8))
|
||||
plt.imshow(image, cmap='gray')
|
||||
plt.colorbar()
|
||||
plt.title("Andor Camera - Single Frame")
|
||||
plt.show()
|
||||
|
||||
# 断开连接
|
||||
cam.close()
|
||||
print("已断开连接")
|
||||
Reference in New Issue
Block a user