I am using PySpin / python wrapper for spinnaker (Flir camera SDK).
There is a cam.ExposureTime.GetValue()
method to get the current exposure time of the camera. I am able to use it like this:
print("Exposure time set to %.2f µs." % cam.ExposureTime.GetValue())
This works fine and prints the exposure time in micro seconds.
Next, I wanted to display time in milliseconds so I did the following:
print("Exposure time set to %.2f ms." % float(cam.ExposureTime.GetValue())/1000)
Python doesn't like it! I get an error:
TypeError: unsupported operand type(s) for /: 'str' and 'int'
A simple statement like float('12.67')/10
runs without any problem. Not sure what is going wrong.
I figured the issue was due to an arithmetic operation on PySpin returned value inside a print
statement. I moved the operation before print
statement and that solved by issue.
I simply used:
exp_time = float(cam.ExposureTime.GetValue())/1000
print("Exposure time set to %.2f ms." % exp_time )