monoCamera codegen error: Handle Classes in top-level outputs are not supported in MATLAB Coder

4 ビュー (過去 30 日間)
li chen
li chen 2020 年 11 月 11 日
コメント済み: li chen 2020 年 11 月 16 日
monoCamera is defined in https://www.mathworks.com/help/driving/ref/monocamera.html?s_tid=srchtitle. and have codegen capability. I try to generate the C++ object with code below:
function sensor = gen_camera(focalLength, principalPoint,imageSize, height,pitch,roll) %#codegen
coder.inline('never');
intrinsics = cameraIntrinsics(focalLength,principalPoint,imageSize);
sensor = monoCamera(intrinsics, height, 'Pitch', pitch, 'Roll', roll);
end
and codegen reports error:
cfg = coder.config('lib');
cfg.HardwareImplementation.ProdHWDeviceType = 'Intel->x86-64 (Linux 64)';
cfg.TargetLang = "C++";
cfg.CppNamespace = 'camera';
cfg.CppNamespaceForMathworksCode = 'MatlabCV';
cfg.HeaderGuardStyle = "UsePragmaOnce";
cfg.PostCodeGenCommand = 'packNGo(buildInfo)';
>> codegen -config cfg -report -o cameraVision gen_camera -args {focalLength, principalPoint,imageSize, height,pitch,roll}
??? Handle Classes in top-level outputs are not supported in MATLAB Coder. Output parameter 'sensor'
contains a handle class.
Anyway to solve this issue?

回答 (1 件)

Aghamarsh Varanasi
Aghamarsh Varanasi 2020 年 11 月 13 日
編集済み: Aghamarsh Varanasi 2020 年 11 月 13 日
Hi Li Chen,
‘sensor' is a Handle class object of the class ‘monoCamera’. A handle class object cannot be an entry-point (top level) function input or output.
Refer this documentation page to declare a MATLAB class that supports codegen.
If the purpose of ‘sensor’ handle class object is just to pass data from one function to another, you could instead convert ‘sensor’ to a structure and pass it as an output argument to the function ‘gen_camera’.
sensor = struct(sensor);
You can add this line at the end of your fucntion gen_camera’.
  1 件のコメント
li chen
li chen 2020 年 11 月 16 日
After adding this line, I got error:
???Struct with one argument is not supported for code generation.
I'm using Matlab R2020b

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeResampling Techniques についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by