Regression in opencv 4.11 when reading double precision matrix data from yaml files
lostoliv opened this issue · 2 comments
lostoliv commented
Reading this yaml file in opencv 4.10 works while failing with opencv 4.11 (all int values like 0 get corrupted in 4.11 - while 0.0 is fine):
%YAML:1.0
matrix1:
rows: 1
cols: 4
dt: d
data: [ 0, 0.0, 1, 1.0 ]
Note that changing dt: d to dt: f works fine.
You can run the following code to repro (assert failing only with 4.11):
# Good: python -m pip install --upgrade opencv-python==4.10.0.84
# Bad: python -m pip install --upgrade opencv-python==4.11.0.86
import cv2, numpy as np
mat_str = '[ 0, 0.0, 1, 1.0 ]'
yaml_file =\
'%YAML:1.0\n'\
'matrix1:\n'\
' rows: 1\n'\
' cols: 4\n'\
' dt: d\n'\
f' data: {mat_str}\n'
node_name = 'matrix1'
fs = cv2.FileStorage(yaml_file, cv2.FILE_STORAGE_MEMORY)
mat = fs.getNode(node_name).mat().flatten()
expected = np.array(eval(mat_str))
print(f'mat from yaml: {mat}')
print(f'mat expected: {expected}')
assert np.allclose(mat, expected)I see some changes related to FileStorage in 4.11 (like opencv/opencv#26434) that might have introduced this regression.
asmorkalov commented
@dkurt Could you take a look? May it be related to int64 support?
dkurt commented
opencv/opencv#26846 resolves this issue too