更新时间:2023-01-08 10:12:28
使用纯OpenCV API调用:
Using pure OpenCV API calls:
// Declare what you need
cv::FileStorage file("some_name.ext", cv::FileStorage::WRITE);
cv::Mat someMatrixOfAnyType;
// Write to file!
file << someMatrixOfAnyType;
文件扩展名可以是 xml 或 yml 。
在这两种情况下,你会得到一个小的头,你可以轻松地删除/解析,然后你可以访问浮点格式的数据。
我使用这个方法成功(使用yml文件)获取数据到Matlab和Matplotlib
The file extension can be xml or yml. In both cases you get a small header that you can easily remove/parse, then you have access to the data in a floating point format. I used this approach successfully (with yml files) to get data into Matlab and Matplotlib
获取数据:
Voilà。如果没有正确猜测图像大小,可能需要在matlab命令行中重新生成矩阵。
Voilà. You may have to reshape the resulting matrix in matlab command line if it didn't guess correctly the image size.