codegen: use -package option error?

When I use the codegen command line for code generation, I get the following error unexpectedly, which I guess is that the matlab built-in function detectORBFeatures calls the OpenCV source code???
inputsArgs = {'-config','cfg',...
'myEntryFcn','-args',{in1,in2},...
'-package','src.zip',...
'-report'};
codegen(inputsArgs{:});
report following bug:
The following files have the same file name which cannot be packaged together in a flat hierarchy:
C:\Program Files\MATLAB\R2022b\toolbox\vision\builtins\src\ocvcg\opencv\include\opencv2\stitching\detail\warpers.hpp
C:\Program Files\MATLAB\R2022b\toolbox\vision\builtins\src\ocvcg\opencv\include\\opencv2\stitching\warpers.hpp
Use help codegen for more information on using this command.
Error using codegen
Run in R2022b.

12 comentarios

Mukund Sankaran
Mukund Sankaran el 26 de Oct. de 2022
Hi @cui, would you be able to share a minimal example that reproduces this issue ? How does your myEntryFcn look like, and what are the arguments and configuration being passed in the codegen command ?
Also, just out of curiosity, does the packaging work if you use packNGo, with the packType option set to 'hierarchical', instead of using the -package option with the codegen command ? Alternatively, you can also try this from within the code generation report, by clicking the 'Package Code' button in the report.
Thank you for your prompt attention to the bug report @Mukund Sankaran
Here is the minimal example to reproduce the bug:
function out = myEntryFcn(grayImg)%#codegen
points = detectORBFeatures(grayImg);
out.Location = points.Location;
out.Metric = points.Metric;
out.Scale = points.Scale;
out.Orientation = points.Orientation;
end
then i using following code in command line:
grayImg = im2gray(imread("peppers.png"));
codegen -config:lib myEntryFcn -args {coder.typeof(grayImg)} -report -package "src.zip"
Then the above error is reported.
My attempts to package in the Coder APP interface also give errors unless the hierarchy directory is maintained.
BTW,detectORBFeatures built-in functions that call the OpenCV library? I set the target platform as embedded "Texas Instruments->C6000", this should not call OpenCV, if so, it is better to write code with OpenCV?
xingxingcui
xingxingcui el 28 de Oct. de 2022
Editada: xingxingcui el 28 de Oct. de 2022
@Mukund SankaranI now think it would be unwise to call the OpenCV library in the C code generated by the TMW product. OpenCV is a high performance computer vision library and TMW could refer to its source code to implement its own proper algorithmic logic and use its own data structure types, rather than generating a wrapper.Hopefully future versions will improve!
Ujwal Durgam
Ujwal Durgam el 28 de Oct. de 2022
Yes, the detectORBFeatures calls the OpenCV library.
When the user sets the platform to a Non-Matlab host target (in this case, "TI->C6000"), the generated code does not include the OpenCV libs, but expects to have OpenCV installed on the target(TI->C6000) and link the installed libraries when compiling the code on the target.
xingxingcui
xingxingcui el 28 de Oct. de 2022
@Ujwal Durgam It would be unkind of TMW to use open source for C code generation like this
Ujwal Durgam
Ujwal Durgam el 1 de Nov. de 2022
@cui Thanks for the feedback, we will take this into consideration.
xingxingcui
xingxingcui el 2 de Nov. de 2022
Editada: xingxingcui el 2 de Nov. de 2022
@Ujwal Durgam Similar questions are suggested:link
xingxingcui
xingxingcui el 3 de Nov. de 2022
Recently I have encountered generated C code or mex files that execute much less efficiently than the original matlab code (because many build-in functions are using pre-compiled libraries). I now instead think that in order to preserve the performance of the generated C code, it is possible to call the opencv library, but add the option for the user to choose whether to use a third party library when generating the configuration.
xingxingcui
xingxingcui el 4 de Mzo. de 2023
@Ujwal Durgam The orb feature C++ code generated by the current R2022b version is dependent on the OpenCV4.X C++ version. If the user additionally has their own version of opencv, say 3.x, this may lead to some function interface conflicts, which can be fixed manually, but it is best to specify this in future matlab documentation.
xingxingcui
xingxingcui el 25 de Jul. de 2023
@Mukund Sankaran ,@Ujwal Durgam Hi, I've recently encountered the packaging problem again, I've tried the previous methods and still can't solve it, the link to the problem is here
Ujwal Durgam
Ujwal Durgam el 25 de Jul. de 2023
-package runs packNGo on the generated code to package all files in a flat hierarchy. In this case, the opencv headers cannot be packed in flat hierarchy as clearly mentioned in the error message.
For this case you need to manually run packNGo with packType='hierarchical'.
xingxingcui
xingxingcui el 25 de Jul. de 2023
Editada: xingxingcui el 25 de Jul. de 2023
Thank your for your reply, I know what you mean, now I'm having a different problem, may I ask if you clicked on the link above?
The large number of dependent header and source files is indeed a tricky issue

Iniciar sesión para comentar.

 Respuesta aceptada

xingxingcui
xingxingcui el 28 de Oct. de 2022
Editada: xingxingcui el 28 de Oct. de 2022

0 votos

The correct approach is for the codegen command to not use the -package option.Then,this bug is easily fixed by manually copying the separate C code.
Also, detectORBFeatures does call a third-party OPENCV library, which is not clearly stated in the official documentation function on the C/C++ generated support description(Extended Capabilities section(bottom page)).Which, in terms of the generated code, is simply a wrapping of the ORB feature detection to fit the C code generation.

Más respuestas (0)

Categorías

Productos

Versión

R2022b

Etiquetas

Preguntada:

el 26 de Oct. de 2022

Editada:

el 25 de Jul. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by