如何将矩阵数据从MATLAB传输到OpenCV,C+?

发布于 2025-02-13 13:15:05 字数 165 浏览 0 评论 0原文

我在MATLAB中有一个57x1双矩阵,我想找到一种保存该数据的方法,然后将其加载到新的OpenCV垫子中。对于实际图像,我曾经在matlab中进行imwrite,然后在OpenCV中进行IMREAD,但是在这种情况下,结果是一个垫子,其所有值等于255。

I have a 57X1 double matrix in Matlab and I want to find a way to save that data and then load it to a new OpenCV Mat. For actual images I used to do imwrite in Matlab and then imread in OpenCV but, in this current situation, the result was a Mat with all of the values equal to 255.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月朦胧 2025-02-20 13:15:05

最简单的方法是仅使用csvwrite将其写入文本文件,然后通过阅读文本文件中的数字来将其加载到C ++中。

如果您必须具有二进制精确值,则可以使用Fopen,fwrite,fclose以二进制格式编写值,然后使用等效函数(即fread或ifstream ::读取)将二进制数据直接读取到“垫子缓冲区” 。

The simplest way is to just use csvwrite to write as a text file, and then load it in C++ by reading the numbers from the text file.

If you must have binary exact values, you can use the fopen, fwrite, fclose to write the values in binary format, and then use the equivalent functions (i.e. fread or ifstream::read) to read the binary data directly to the Mat buffer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文