c++ - 错误 : '' cannot convert 'uint8* {aka unsigned int*}' to 'const emxArray_uint8_T*' ? '?

标签 c++ image matlab mex matlab-coder

我编写了一个 matlab 函数来计算图像“ent=entropoy(image)”的熵,并通过 matlab 编码器将其转换为 c++ 函数。

我在 c++ 文件中进行了一些计算,然后尝试将所有 c++ 代码转换为 matlab 函数。

我收到了

error: 'cannot convert 'uint8* {aka unsigned int*}' to 'const emxArray_uint8_T*'

在熵函数中

如何在 mex 函数中声明图像 'which input from matlab' 并在熵函数中正确使用它?

最佳答案

要创建 emxArray_uint8_T,您需要使用 Coder 为您生成的一些辅助函数,例如 emxCreate_uint8_T

MATLAB Coder 生成的 emxArray_*_T 类型是用于在生成的代码中存储动态分配数据的结构。它们包含数据指针、大小 vector 和其他用于管理动态分配的元数据。

在 MATLAB R2015a 及更新版本中,在 examples 目录下的生成代码中查找文件 main.cmain.h。这些将为您提供示例 C 或 C++ 主函数,向您展示如何正确构造输入和调用生成的代码。

答案:

https://stackoverflow.com/a/24271438/3297440

还更详细地介绍了如何使用生成的 emxArray 类型,并提供了指向 MATLAB Coder 文档的链接。

关于c++ - 错误 : '' cannot convert 'uint8* {aka unsigned int*}' to 'const emxArray_uint8_T*' ? '?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50173696/

相关文章:

c++ - MySQL C API : Segmentation Fault when running query from different thread

c++:如何将字符串的其余部分存储在变量中?

c++ - 使用 for 循环格式化 C++

sql - 如何使用 WPF 将图像插入数据库

javascript - 如何查找 src 为空的 Img 标签。并删除它

java - 将彩色图像转换为背景/白色图像

c++ - 模板类构造函数采用模板类的实例

matlab - 在 Matlab 中用 feedforwardnet 模拟默认 patternnet?

正则表达式在 Matlab 中的行为不符合预期

图像的Matlab大小