Matlab Coder Target - Example MATLAB function for edge detection.

1 view (last 30 days)
Hello
I am running a Matlab 2018 a with Linux Os ,
I have a raspberry PI 3 , and I would like to work with Matlab code target , so I tried the
example that is provided with the package it self .
the function is :
function myApplication()
%myApplication Example MATLAB function for edge detection.
%#codegen
% Copyright 2017-2018 The MathWorks, Inc.
w = matlab.raspi.webcam(0,[320,240]);
d = matlab.raspi.SDLVideoDisplay;
% Main loop
kern = [1 2 1; 0 0 0; -1 -2 -1];
for k = 1:1000
img = snapshot(w);
h = conv2(img(:,:,2),kern,'same');
v = conv2(img(:,:,2),kern','same');
e = sqrt(h.*h + v.*v);
edgeImg = uint8((e > 100) * 240);
displayImage(d,edgeImg);
end
release(w);
release(d);
end
after that I intialize the connection with PI and launching the application
r= raspi
r =
raspi with properties:
DeviceAddress: 'XXXXXXXXXX'
Port: XXXX
BoardName: 'Raspberry Pi 3 Model B'
AvailableLEDs: {'led0'}
AvailableDigitalPins: [4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]
AvailableSPIChannels: {'CE0','CE1'}
AvailableI2CBuses: {'i2c-1'}
AvailableWebcams: {'DEF-299 Camera (usb-3f980000.usb-1.2):','DEF-299 Camera (usb-3f980000.usb-1.3):'}
I2CBusSpeed: 100000
Supported peripherals
>> runOnHardware(r,'myApplication')
Code generation successful: View report
but I got a black screen with the screen atached to PI , any Help please why I got the black screen and how I can solve this problem ?
Thank You very Much
the following link is for the package it self

Answers (1)

Reeno Joseph
Reeno Joseph on 21 May 2020
Hello Abdelrahman,
I'm guessing you are using the MathWorks customized Raspbian image.
The video display is not showing up in the HDMI due to a bug in the SDL library. For more details please refer https://github.com/raspberrypi/firmware/issues/913
As a workaround, you can flash the SD card with a full version of Raspbian(with GUI) and customize it to work with MATLAB -- please follow the OS customization steps in the hardware setup screen.
I hope this helps.
Thanks,
Reeno Joseph

Categories

Find more on MATLAB Coder in Help Center and File Exchange

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!