gpt4 book ai didi

c++ - 在 opencv 中使用文件存储

转载 作者:太空宇宙 更新时间:2023-11-03 22:32:37 25 4
gpt4 key购买 nike

我正在尝试使用 cv::FileStorage 将我的相机矩阵保存到 yml 文件中,这个工作正常:

cv::FileStorage  fs("calibration_result.yml",cv::FileStorage::WRITE);

..............

this->fs << "the camera matrix is "<<this->cameraMatrix;

这是我得到的:

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. ]

我想得到的是:

the camera matrix is :
[ 6.9722486929603847e+003, 0., 6.3950000000000000e+002, 0.,
7.0010247500898549e+003, 5.1150000000000000e+002, 0., 0., 1. ]

我已经尝试使用 cameraMatrix.data 它没有帮助!

知道我该怎么做!

提前致谢!

最佳答案

cameraMatrix 应具有类型 cv::Matcv::Mat 以这种方式保存,如 modules/core/src/persistence.cpp 所示(参见 icvWriteMat)如果没有额外的数据,OpenCV 将无法理解 cv::Mat 大小(这是 [...] 3x3 还是 1x9 矩阵?)通常使用 writting以后再读写。您可以使用一些原始编写技术编写您想要的内容(并且无法使用 opencv 读取它)或制作您自己的可序列化 matrix3x3cameraMatrix 类型。

关于c++ - 在 opencv 中使用文件存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19241313/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com