image thumbnail

在硬件上运行

version 2.0.7 (1.29 MB) by MathWorks MATLAB Coder Team
演示如何在Raspberry Pi硬件上运行MATLAB代码的示例。
3.1
10评级

44 Downloads

更新11 Aug 2020

View License

NOTE: MATLAB release R2018b onwards, the functionality provided in this File Exchange submission is now a part of the MATLAB Support Package for Raspberry Pi Hardware.
For more information, please visit the following links:
Documentation://www.tatmou.com/help/supportpkg/raspberrypiio/run-on-hardware.html
Video:https://www.youtube.com/watch?v=5lkCx8-zJm0

This package includes examples from image processing and audio signal processing domains that demonstrate the workflow of generating C code from a MATLAB algorithm and running it on hardware as a stand-alone application using MATLAB Coder. A MATLAB function, called runOnHardware, is provided for deploying a MATLAB algorithm for prototyping on a Raspberry Pi hardware board.

The Sobel Edge detection example includes the system objects for capturing images from a USB webcam and for displaying images on the Raspberry Pi desktop.

Cite As

MathWorks MATLAB Coder Team (2020).在硬件上运行(//www.tatmou.com/matlabcentral/fileexchange/62243-run-on-hardware), MATLAB Central File Exchange. Retrieved.

评论和评级(25)

Murat Belge

@Mikael Kurula:Exhange提交的文件中提供的所有功能现在都是Raspberry Pi硬件的MATLAB支持包的一部分。如果您有matlabr2019a或更高版本,可以使用raspi接口将MA金宝appTLAB代码部署到Raspberry-Pi。查看演示://www.tatmou.com/help/supportpkg/raspberrypiio/examples.html?category=run-on-hardware&s_tid=CRUX_lftnav_example_connection-to-raspberry-pi-hardware.

Mikael Kurula

In order to be able to deploy the pitch shift example to the rpi, I had to remove ".internal" on line 3 of the file /home/mkurula/MATLAB Add-Ons/Toolboxes/Run on Hardware/+matlab/raspi/AudioCapture.m.

Mikael Kurula

When I tried to deploy the edge detect example to the Raspberry Pi, I got some error message complaining about not finding main.c, and indeed there is no such file where it is supposed to be. The solution is to comment out lines 50-51 and add one line directly after to the file /home/mkurula/MATLAB Add-Ons/Toolboxes/Run on Hardware/runOnHardware.m:
%cfg.CustomInclude = fullfile('codegen','exe',fcnName,'example');
%cfg.CustomSource = fullfile('codegen','exe',fcnName,'examples','main.c');
cfg.GenerateExampleMain = 'GenerateCodeAndCompile';

ibrahim ahmethan

i am traying to download it but there is something wrong it is hanging so please help me

dgmcik

Mohith Prabhu

@Ashwini Patil: targetHardware support starts from R2018a release of MATLAB

Ashwini Patil

hi,i am using R2017b version and i get the error for creating configuration object for hardware
boaed=targetHardware(r,'myApplication')
我收到错误
未定义的函数或变量targetHardware
can i help me solve this problem

Henry Murr

Henry Murr

The function automatically saves as a log file on the raspberry pi when it needs to be an elf file. Can anyone help me fix this problem?

Marion Pontier

problem of download

Jaeseon Lee

下载是挂! !

Murat Belge

@Afagh: The error message says 'unit8' not 'uint8'. You might have a typo somewhere.

afagh mohagheghi

Hello, I am using R2017b version and I get the following error:
runOnHardware(r,'myApplication')
??? 未定义的函数或变量“unit8”。

==>myApplication行:11列:13中出错
代码生成失败:查看错误报告
Error using codegen

runOnHardware出错(第52行)
codegen('-config',cfg,fcnName,'-report');

which does not make any sense because I use the uint8 right there in the command prompt and it works perfectly. Would anyone have an idea why this is happening? Thanks in advance for your help.

Jyot Buch公司

Murat Belge

For R2018a users: use "raspberrypi" object when calling runOnHardware function. That is:

>> r = raspberrypi;
>> runOnHardware(r,'myFunction')

Using "raspi" object results in runOnHardware throwing an error.

Murat Belge

@michele benetti: This example requires Embedded Coder license in addition to MATLAB Coder for R2018a and earlier. This dependency was stated in the overview section. I'll update the description accordingly. The error message you are seeing is due to the Embedded Coder requirement.

michele benetti

hi, I have installed the package but when I run
runOnHardware(r,'myApplication')
I receive as error:
Trial>> runOnHardware(r,'myApplication')
Error using coder.hardware

There are no hardware support packages installed that support Processor-in-the-Loop (PIL)
simulation.
以下支持包支持使用MATLA金宝appB编码器进行PIL模拟:

Embedded Coder Support Package for BeagleBone Black Hardware
Xilinx Zynq-700金宝app0平台嵌入式编码器支持包
Embedded Coder Support Package for Altera SoC Platform
Embedded Coder Support Package for ARM Cortex-A Processors
Embedded Coder Support Package for ARM Cortex-M Processors
Embedded Coder Support Package for STMicroelectronics Discovery Boards

runOnHardware出错(第41行)
hw = coder.hardware('Raspberry Pi');

Krishna

Hi, I am not sure why I am receiving this error.
##########################################
Error using coder.ceval (line 48)
The coder.ceval function is not supported in MATLAB.

音频捕获/打开错误(第57行)
coder.ceval('MW_AudioOpen',...

Error in pitchShiftDeployment (line 17)
打开(capture,4410,2)
##########################################

betül zengin

Why not turn on the camera

function bet2()
%#codegen
%版权所有2017 The MathWorks,Inc。
persistent w
persistent d
如果是空的(w)
w = matlab.raspi.webcam(0,[640,480]);
d = matlab.raspi.SDLVideoDisplay;
end

for k = 1:1000

img = snapshot(w);

Rmin=25;
Rmax=35;

[centersDark, radiiDark] = imfindcircles(img, [Rmin Rmax], ...
'ObjectPolarity','dark','sensitivity',0.93);

视图([中心标记,半径标记])


for i=1:length(radiiDark)
等等
视图([中心标记,半径标记])
暂缓
RGB = insertShape(img,'circle', [centersDark(i,1),centersDark(i,2),radiiDark(i)] ,'LineWidth',5);

displayImage(d,RGB);

end
end

释放(w);
release(d);

Murat Belge

@Ola Olsson: The output of fprintf goes to stdout. In the runOnHardware function, I direct the output to a *.log file. For example, if your M-file is called myApplication.m and you compile and generate code out of it, the output of the application myApplication.elf goes to myApplication.log file. And by default the *.log file is generated in the same directory where you launch the application. So check the *.log file for output.

有一种方法将输出发送到文件r choice. This is illustrated in raspberrypi_motion_sensor_camera.slx. There is a MATLAB function block in this Simulink demo where we save an image to disk. Take a look at that for details.

Ola Olsson

Really great example. Thanks for providing this! I am about to try to develop a little computer vision tool, and this is a very good start. Now, in that I also want to save some numbers to a text file on disk on the Raspberry Pi, using fprintf. However, it seems that either it does not do anything with it, or it puts the file in place where I am unable to find it. The code generation report is not complaining (as it was when I tried to fprintf an array instead of scalars), so there is no guidance there.

猛撞

Add your comments on the example and the proposed workflow in the comment section and let us know if you would like to have a more detailed discussion.

猛撞

猛撞

Updates

2.0.7

更新the description

2.0.6

Added a documentation link.

2.0.5

Added link to YouTube Video

2.0.4

更新the description.

2.0.3

Fixed a minor issue where URL encoded spaces are inserted into the directory names when installing manually instead of using the add-on explorer.

2.0.2

小更新。

2.0.1

为新版本更新。

2.0.0.0

更新dependency - Embedded Coder

2.0.0.0

Added a new video

2.0.0.0

New audio signal processing example added.

1.0.0.0

添加了视频链接。

1.0.0.0

更新了标题和缩略图。

MATLAB版本兼容性
使用R2018a创建
Compatible with R2017a to R2018a
Platform Compatibility
窗户 macOS Linux

Pitch_Shift_Example

发出呜咽声el_Edge_Detection