I have written a matlab function to calculate entropy of image "ent=entropoy(image)" and convert it to c++ function by matlab coder.
I do some calculation at ent in c++ file then try to convert all c++ code to matlab function.
I received the
error: 'cannot convert 'uint8* {aka unsigned int*}' to 'const emxArray_uint8_T*'
in entropy function
How declare image 'which input from matlab' in mex function and use it correctly in entropy function?
To create an emxArray_uint8_T you'll need to use some of the helper functions that Coder generates for you like emxCreate_uint8_T.
The generated emxArray_*_T types from MATLAB Coder are structs used to store dynamically allocated data in the generated code. They contain a data pointer, size vector, and other metadata to manage dynamic allocation.
In MATLAB R2015a and newer, look for the files main.c and main.h in the generated code under the examples directory. Those will give you an example C or C++ main function that show you how to properly construct inputs and invoke the generated code.
The answer:
https://stackoverflow.com/a/24271438/3297440
also covers using the generated emxArray types in more detail and gives links to the MATLAB Coder documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With