How can I generate c code for inbuilt MATLABfunction using codegen ?

1 次查看(过去 30 天)
codegen worked fine in simple functions I wrote. I have to generate c code forestimateGeometricTransform
1)Tried with all inputs defined | *
codegen estimateGeometricTransform -args {M1,M2,ch} -report -config:lib
*Error recieved* * _:The extrinsic function 'projective2d' is not available for standalone code generation. It must be eliminated for stand-alone code to be generated. It could not be eliminated because its outputs appear to influence the calling function. Fix this error by not using 'projective2d' or by ensuring that its outputs are unused.
Error in ==> estimateGeometricTransform Line: 174 Column: 17 Code generation failed: Open error report. Error using codegen (line 144)_ *
2)So tried to bypass code generation of projective2d by addinf a line in the inbuilt function
coder.extrinsic ('affine2d','projective2d');
*Error recieved* same as above
3)tried to eliminate line of code where ' * projective2d' * appears
%tform = projective2d(tmatrix);
Error recieved Output argument 'tform' is not assigned on some execution paths.
Error in ==> estimateGeometricTransform Line: 1 Column: 11 Code generation failed: Open error report. Error using codegen (line 144)

采纳的回答

Andy Sonnenburg
Andy Sonnenburg 2014-7-25
New versions of MATLAB Coder should support
projective2d
for code generation (R2013a and later). See projective2d for more information.
Adding
coder.extrinsic('projective2d')
will not help when compiling with
-config:lib
where the extrinsic function has a side effect - usually via an output variable. Put another way, coder.extrinsic will only help when compiling with -config:lib if the the use of the function is "dead". See coder.extrinsic for more information.
The commenting out of the line that assigns tform results in an error because tform can no longer be proven to be definitely assigned before first used. For example, changing
tform = ...
foo(tform)
to
% tform = ...
foo(tform)
will result in an error because tform will not definitely be assigned before use (and in this example, is never assigned before use).
  2 个评论
Avithal
Avithal 2014-7-27
Hi Andy , It really helped me , commented the variable and generated the code . I am on the trial version of MATLAB2014a, maybe that is the problem with projective2d.
Ryan Livingston
Ryan Livingston 2014-7-28
In R2014a, projective2d should be supported for code generation. Search for it here:
When something is "supported for code generation" there is generally no need to use coder.extrinsc. You should be able to just remove the:
coder.extrinsic('projective2d')
from your code.
Then you will be able to call projective2d in your code and generate code that uses its output. So:
tform = projective2d(tmatrix);
should be perfectly allowed without the coder.extrinsic call for projective2d.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Generating Code 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by