我有以下测试.yaml:
Camera.ColourOrder: "RGB"
Camera.ColourDepth: "UCHAR_8"
Camera.Spectrum: "Visible_NearIR"
IMU.T_b_c1: !!opencv-matrix
rows: 4
cols: 4
dt: f
data: [0.999903, -0.0138036, -0.00208099, -0.0202141,
0.0137985, 0.999902, -0.00243498, 0.00505961,
0.0021144, 0.00240603, 0.999995, 0.0114047,
0.0, 0.0, 0.0, 1.0]
我正在try 使用python OpenCV cv2
模块来读取它(因为它包含与OpenCV相关的对象,比如嵌入在YAML中的opencv_matrix
,如果try 使用Python内置的YAML模块来读取,它将会给出错误).但它给我的错误如下所示:
>>> import os
>>> 'test.yaml' in os.listdir()
True
>>> import cv2
>>> fs = cv2.FileStorage("test.yaml", cv2.FILE_STORAGE_READ)
cv2.error: OpenCV(4.8.1) /io/opencv/modules/core/src/persistence.cpp:699: error: (-5:Bad argument) Input file is invalid in function 'open'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: <class 'cv2.FileStorage'> returned a result with an error set
我try 删除IMU.T_b_c1
个值,只保留Camera.xyz
个值,仍然是相同的错误.我在这里错过了什么?
PS:有没有其他方法/模块来读取这种嵌入了OpenCV对象的YAML文件?我可以不使用CV2,并阅读一些其他的包/模块.