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.
Here is a video showing you how you can try the edge detection example included in this entry:
The Pitch shifting example demonstrates how you can deploy an audio processing application to a Raspberry Pi using MATLAB code generation capabilities.
This example shows how to generate code from a simple audio processing function in MATLAB for standalone deployment to a Raspberry Pi for real-time prototyping purposes. System Objects used for capture and playback of audio data from the Raspberry Pi are included in the example.
Here is a video showing you how you can try the audio processing example included in this entry:
MathWorks MATLAB Coder Team (2019). Run on Hardware (https://www.mathworks.com/matlabcentral/fileexchange/62243-run-on-hardware), MATLAB Central File Exchange. Retrieved .
i am traying to download it but there is something wrong it is hanging so please help me
@Ashwini Patil: targetHardware support starts from R2018a release of MATLAB
hi,i am using R2017b version and i get the error for creating configuration object for hardware
i received error
undefined function or variable targetHardware
can i help me solve this problem
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?
problem of download
download is hanging!!
@Afagh: The error message says 'unit8' not 'uint8'. You might have a typo somewhere.
Hello, I am using R2017b version and I get the following error:
??? Undefined function or variable 'unit8'.
Error in ==> myApplication Line: 11 Column: 13
Code generation failed: View Error Report
Error using codegen
Error in runOnHardware (line 52)
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.
For R2018a users: use "raspberrypi" object when calling runOnHardware function. That is:
>> r = raspberrypi;
Using "raspi" object results in runOnHardware throwing an error.
@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.
hi, I have installed the package but when I run
I receive as error:
Error using coder.hardware
There are no hardware support packages installed that support Processor-in-the-Loop (PIL)
The following support packages provide support for PIL simulation with MATLAB coder:
Embedded Coder Support Package for BeagleBone Black Hardware
Embedded Coder Support Package for Xilinx Zynq-7000 Platform
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
Error in runOnHardware (line 41)
hw = coder.hardware('Raspberry Pi');
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.
Error in AudioCapture/open (line 57)
Error in pitchShiftDeployment (line 17)
Why not turn on the camera
% Copyright 2017 The MathWorks, Inc.
w = matlab.raspi.webcam(0,[640,480]);
d = matlab.raspi.SDLVideoDisplay;
for k = 1:1000
img = snapshot(w);
[centersDark, radiiDark] = imfindcircles(img, [Rmin Rmax], ...
RGB = insertShape(img,'circle', [centersDark(i,1),centersDark(i,2),radiiDark(i)] ,'LineWidth',5);
@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.
There is a way to send the output to a file of your 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.
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.
Fixed a minor issue where URL encoded spaces are inserted into the directory names when installing manually instead of using the add-on explorer.
Updated for new releases.
Updated dependency - Embedded Coder
Added a new video
New audio signal processing example added.
Added the video link.
Updated title and thumbnail image.