Files
vinniesniper-54816/task1/_lab/016-demo_SIFT/load_save_yaml.py
louiscklaw 3b0b154910 update,
2025-02-01 01:19:51 +08:00

16 lines
339 B
Python

import cv2
import numpy as np
# Create some data
data = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
# Write to XML
fs = cv2.FileStorage("data.yaml", cv2.FILE_STORAGE_WRITE)
fs.write("data", data)
fs.release()
# Read from XML
fs = cv2.FileStorage("data.yaml", cv2.FILE_STORAGE_READ)
data_read = fs.getNode("data").mat()
print(data_read)