Reputation: 5422
I'm trying to save my cameramatrix into a yml file using cv::FileStorage , this work fine :
cv::FileStorage fs("calibration_result.yml",cv::FileStorage::WRITE);
..............
this->fs << "the camera matrix is "<<this->cameraMatrix;
here is what I get :
the camera matrix is : !!opencv-matrix /* why do I get this
rows:
cols: 3
dt: d
data: [ 6.9722486929603847e+003, 0., 6.3950000000000000e+002, 0.,
7.0010247500898549e+003, 5.1150000000000000e+002, 0., 0., 1. ]
what I want to get is :
the camera matrix is :
[ 6.9722486929603847e+003, 0., 6.3950000000000000e+002, 0.,
7.0010247500898549e+003, 5.1150000000000000e+002, 0., 0., 1. ]
I already tried to use cameraMatrix.data
it didn't help!
any idea how can I do this!
thanks in advance !
Upvotes: 1
Views: 3121
Reputation: 2201
cameraMatrix should have type cv::Mat
. cv::Mat
is saved this way as can be seen in modules/core/src/persistence.cpp
(see icvWriteMat
)
OpenCV won't be able to understand cv::Mat
size without that additional data (is this [...]
3x3 or 1x9 matrix?) and writting is usually used to read written later. You could write what you want using some raw writting techniques (and won't able to read it using opencv) or make your own serializable matrix3x3
or cameraMatrix
type.
Upvotes: 2