from cv2 import cv
import numpy as np
filepath = "test.yml"
matrixA = np.array( cv.Load(filepath, cv.CreateMemStorage(), "matrixA") )
matrixB = np.array( cv.Load(filepath, cv.CreateMemStorage(), "matrixB") )
print "matrixA:", matrixA
print "matrixB:", matrixB
# The following is the "test.yml" file
#======================================================================
# %YAML:1.0
# matrixA: !!opencv-matrix
# rows: 2
# cols: 5
# dt: f
# data: [ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9. ]
# matrixB: !!opencv-matrix
# rows: 3
# cols: 4
# dt: f
# data: [ 5.00000000e-001, 1.50000000e+000, 2.50000000e+000,
# 3.50000000e+000, 4.50000000e+000, 5.50000000e+000,
# 6.50000000e+000, 7.50000000e+000, 8.50000000e+000,
# 9.50000000e+000, 1.05000000e+001, 1.15000000e+001 ]
#======================================================================
this is nice! I read it ok with a matrix. How about reading a constant? double or integer?
ReplyDelete