how to Specify the arguments of imfilter in codegen function ? how to call it with the right parameters ?

조회 수: 8 (최근 30일)
Hallo everybody,
i'm trying to optimize the run time of my App by getting imfilter function called as a C Code .
so first i used the following codegen code to creat a the C Liberies :
codegen -d imfilterlib -config:lib imfilter -args {zeros(3456,5184,'double'),zeros(399,399,'double')}
so im not sure if the input arugments here are the right one, for an Array 3456 x 5184 class double for the first argument for example.
the filles are generated and saved with out any problem
now when using coder.cval function calling the generated function comes allways the error that coder.cval function is not supported in Matlab.
coder.cinclude('imfilter_initialize.h');
coder.cinclude('imfilter.h');
coder.cinclude('imfilter_terminate.h');
coder.ceval('imfilter_initialize');
as showen in the screenshot :
is it something to do with the matlab version i did somthingwrong using the function. i would be very thankfull if you can help.
thanks a lot.
best regards

답변 (2개)

Harsh
Harsh 2025년 2월 23일
The coder.ceval function can only be used in the generated code. Therefore calls made to coder.ceval in MATLAB execution produce an error. You can include a check in your code to run the “coder.ceval” in generated code only by using the “coder.target” function. Below is a sample code snippet to do so:
if coder.target('MATLAB')
% Executing in MATLAB, call MATLAB equivalent of C function imfilter
else
% Executing in generated code, call C function imfilter
coder.updateBuildInfo('addIncludedPaths','$(START_DIR)\codegen\imfilterlib’);
coder.cinclude('imfilte.h');
y = coder.ceval('imfilter', coder.ref(double(app.ROI), double(mask)));
end
For more information regarding “coder.ceval” function, run the following command:
doc coder.ceval

Walter Roberson
Walter Roberson 2025년 2월 24일
To call C code from inside MATLAB, you use loadlibrary followed by calllib

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by