problems in generating c code for raspberry pi: availableW​ebcam.c:(.​text+0x1fc​): `main_terminate' not define

1 次查看(过去 30 天)
here i use the matlab coder for generting code for raspberry pi by using the code below:
cfg = coder.config('exe');
host = raspi('xxx.xxx.xx.xx','pi', 'pi');
cfg.TargetLang = 'C++';
dlcfg = coder.DeepLearningConfig('arm-compute');
dlcfg.ArmArchitecture = 'armv7';
dlcfg.ArmComputeVersion = '19.02';
cfg.DeepLearningConfig = dlcfg;
cfg.Hardware = coder.hardware('Raspberry Pi');
cfg.Hardware.BuildDir = '/home/pi/matlab_arm_codegen/';
%cfg.VerificationMode = 'PIL';
%cfg.GenerateExampleMain = 'GenerateCodeOnly';
cfg.CustomInclude = fullfile('codegen','exe','yolov2_detect_arm','examples');
cfg.CustomSource = fullfile('codegen','main.cpp');
codegen('-config',cfg,'yolov2_detect_arm','-report');
but when i want to compile the exe file this error occured and I cannot find out a solution for that, can anyone help?
availableWebcam.c.o: 関数 `getCameraAddrIndex' :
availableWebcam.c:(.text+0x1fc): `main_terminate' に対する定義されていない参照です
availableWebcam.c.o: 関数 `validateResolution' :
availableWebcam.c:(.text+0x30c): `main_terminate' に対する定義されていない参照です
availableWebcam.c.o: 関数 `getCameraList' :
availableWebcam.c:(.text+0x74c): `main_terminate' に対する定義されていない参照です
collect2: error: ld returned 1 exit status
make: *** [/home/pi/matlab_arm_codegen//MATLAB_ws/R2020a/C/WORK/matlab/yolov2arm/yolov2_detect_arm.elf] エラー 1
  2 个评论
Denis Gurchenkov
Denis Gurchenkov 2020-7-23
Hi,
Can you please attach yolov2_detect_arm.m and other files that are required to reproduce this? Also, is main.cpp generated by codegen is it copied by you from elsewhere?
liheng mo
liheng mo 2020-7-28
hi
thank you for your reply. here i attach the .m file and main.cpp file that are required to reproduce. the main.cpp file is generated by codegen automatically.
yolov2_detect_arm.m
function yolov2_detect_arm()
persistent yolov2obj;
%for raspberry pi opencv library build
opencv_linkflags = '`pkg-config --cflags --libs opencv`';
coder.updateBuildInfo('addLinkFlags',opencv_linkflags);
if isempty(yolov2obj)
yolov2obj = coder.loadDeepLearningNetwork('yolov2.mat','yolov2');
end
host = raspi;
cam = host.webcam;
imgsize = [416,416,3];
fps = 0;
for k = 1:1800
img = snapshot(cam);
img = imresize(img,imgsize(1:2));
tic;
[bboxes,~,labels] = detect(yolov2obj,img);
elapsedtime = toc;
fps = 0.9*fps + 0.1*(1/elapsedtime);
if isempty(bboxes) || isempty(labels)
img = insertText(img, [5,5],fps);
displayImage(host,img);
else
img = insertObjectAnnotation(img,'rectangle',bboxes,labels);
img = insertText(img,[5,5],fps);
displayImage(host,img);
end
end
end
main.cpp
//
// Trial License - for use to evaluate programs for possible purchase as
// an end-user only.
//
// main.cpp
//
// Code generation for function 'main'
//
//***********************************************************************
// This automatically generated example C++ main file shows how to call
// entry-point functions that MATLAB Coder generated. You must customize
// this file for your application. Do not modify this file directly.
// Instead, make a copy of this file, modify it, and integrate it into
// your development environment.
//
// This file initializes entry-point function arguments to a default
// size and value before calling the entry-point functions. It does
// not store or use any values returned from the entry-point functions.
// If necessary, it does pre-allocate memory for returned values.
// You can use this file as a starting point for a main function that
// you can deploy in your application.
//
// After you copy the file, and before you deploy it, you must make the
// following changes:
// * For variable-size function arguments, change the example sizes to
// the sizes that your application requires.
// * Change the example values of function arguments to the values that
// your application requires.
// * If the entry-point functions return values, store these values or
// otherwise use them as required by your application.
//
//***********************************************************************
// Include files
#include "main.h"
#include "DeepLearningNetwork.h"
#include "matlabCodegenHandle.h"
#include "rt_nonfinite.h"
#include "yolov2_detect_arm.h"
#include "yolov2_detect_arm_terminate.h"
// Function Declarations
static void main_yolov2_detect_arm();
// Function Definitions
static void main_yolov2_detect_arm()
{
// Call the entry-point 'yolov2_detect_arm'.
yolov2_detect_arm();
}
int main(int, const char * const [])
{
// The initialize function is being called automatically from your entry-point function. So, a call to initialize is not included here.
// Invoke the entry-point functions.
// You can call entry-point functions multiple times.
main_yolov2_detect_arm_vid();
// Terminate the application.
// You do not need to do this more than one time.
yolov2_detect_arm_vid_terminate();
return 0;
}
// End of code generation (main.cpp)

请先登录,再进行评论。

回答(1 个)

Reeno Joseph
Reeno Joseph 2020-7-30
Hi Liheng,
We have a limitation with codegen for Raspi peripherals -- Need to add some explicit init/terminate calls.
So if you are using any raspi peripherals within the MATLAB function, Please use the 'Run on Hardware' workflow. This is a simplified version of 'codegen' command with target specific inti/terminate calls. Please have a look at the featured example as well.
For your particular example, please try these commands:
board = targetHardware('Raspberry Pi')
board.CoderConfig.TargetLang = 'C++'
dlcfg = coder.DeepLearningConfig('arm-compute');
dlcfg.ArmArchitecture = 'armv7';
board.CoderConfig.DeepLearningConfig = dlcfg
deploy(board,'yolov2_detect_arm')
  1 个评论
liheng mo
liheng mo 2020-7-31
hi, thank you for your reply.
with the deploy workflow I can sucessfully generate the programme, but i got another error when I try to run on the raspberry pi.
terminate called after throwing an instance of 'std::runtime_error'
what(): in validate_arguments src/core/NEON/kernels/NEDepthwiseWeightsReshapeKernel.cpp:92: biases->dimension(0) != input->dimension(2)
Aborted
it seems that it is caused by the computelibrary I think. the computeversion that i use is 19.02

请先登录,再进行评论。

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by