当前,我正在比较Python脚本中两个图像的关键点。如果运行比较脚本,将比较图像一的关键点和图像二的关键点,并显示一个百分比。
当我尝试在每次运行脚本后将比较结果连续放置在Pandas Data框架中时,就会遇到麻烦。目前,Pandas Data-frame正在替换旧结果。您认为我如何解决这个问题?
# Create a pandas data frame with the data from the comparison.
initial_data = {'Key_points_1': [int(len(kp_1))],
'Key_points_2': [int(len(kp_2))],
'Percentage': [percentage]}
df = pd.DataFrame(initial_data, columns=['Key_points_1', 'Key_points_2', 'Percentage'])
result = []
for value in df["Percentage"]:
if value >= 15:
result.append("Pass") # Threshold to be defined.
else:
result.append("Fail") # Threshold to be defined.
df["Result"] = result
# Solution to keep the previous results in the file.
df.to_csv('output/cvs_DataFrame.csv', sep='\t', encoding='utf-8')
我希望每次运行脚本后,Pandas Data-frame都会在每次运行脚本时保留比较结果。