1

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 !

4

1 回答 1

2

cameraMatrix 应该有类型cv::Matcv::Mat以这种方式保存,如modules/core/src/persistence.cpp(请参阅icvWriteMat)OpenCV 将无法在cv::Mat没有附加数据的情况下理解大小(这是[...]3x3 还是 1x9 矩阵?),并且写入通常用于稍后读取写入。您可以使用一些原始书写技术编写您想要的内容(并且无法使用 opencv 读取它)或使您自己的可序列化matrix3x3cameraMatrix类型。

于 2013-10-08T09:10:08.450 回答