spinnaker返回的曝光时间不喜欢算术运算

2024-05-15 02:28:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用spinnaker的PySpin/python包装器(Flir摄像头SDK)

有一种cam.ExposureTime.GetValue()方法可以获取相机的当前曝光时间。我可以这样使用它:

print("Exposure time set to %.2f µs." % cam.ExposureTime.GetValue())

它工作良好,以微秒为单位打印曝光时间

接下来,我想以毫秒为单位显示时间,因此我执行了以下操作:

print("Exposure time set to %.2f ms." % float(cam.ExposureTime.GetValue())/1000)

Python不喜欢它!我得到一个错误:

TypeError: unsupported operand type(s) for /: 'str' and 'int'

float('12.67')/10这样的简单语句运行起来没有任何问题。不知道出了什么问题


Tags: totime时间单位floatexposure摄像头print
1条回答
网友
1楼 · 发布于 2024-05-15 02:28:50

我认为问题是由于在print语句中对PySpin返回的值进行了算术运算。我将操作移到了print语句之前,并通过问题解决了该操作

我只是用了:

exp_time = float(cam.ExposureTime.GetValue())/1000
print("Exposure time set to %.2f ms." % exp_time )

相关问题 更多 >

    热门问题