我使用PySpin / python wrapper for spinnaker (Flir camera 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这样的简单语句运行起来没有任何问题。不确定哪里出了问题。
发布于 2020-08-27 07:31:10
我认为这个问题是由于在print语句中对PySpin返回值进行算术运算造成的。我将操作移到了print语句之前,并通过问题解决了它。
我只是简单地使用了:
exp_time = float(cam.ExposureTime.GetValue())/1000
print("Exposure time set to %.2f ms." % exp_time )https://stackoverflow.com/questions/63588900
复制相似问题