我必须将摄像机距离导出到txt /数据文件。 当我在工作时出现错误时。
任何想法如何克服它。
未发布完整的代码
perimeter = cv2.arcLength(cnt,True)
g = float("{0:.2f}".format(perimeter))
timestamped_camera_readings = np.append(timestamped_sensor_readings, (((154*58)/(g/4))*0.2645 ))
with open("camera_diatance.txt", "ab") as f:
np.savetxt(f, np.expand_dims(timestamped_camera_readings, axis=0), fmt=write_fmt)
Error raised:
Traceback (most recent call last):
File "/home/pi/merger/merger.py", line 118, in <module>
np.savetxt(f, np.expand_dims(timestamped_camera_readings,
axis=0),fmt=write_fmt)
File "/usr/lib/python3/dist-packages/numpy/lib/npyio.py", line 1196, in
保存文本 引发错误 ValueError:fmt的%格式数量错误:%4.2f%4.2f%4.2f%4.2f %4.2f%4.2f%4.2f%4.2f%.0f