Display image on a raspberry pi

Hello
I'm trying to use the 'displayimage' function seen here: https://www.mathworks.com/help/supportpkg/raspberrypiio/ref/displayimage.html
I'm simply trying to display a .png image on a monitor connected to my raspberry pi. I have installed MATLAB Support Package for the Raspberry Pi as well as MATLAB coder. I am able to communicate with my pi, and my script runs just fine on MATLAB. The image pops up on in a MATLAB window but nothing shows up on the monitor attached to my pi. Here's my code:
function ImageDisplayTest()%#codegen directive
% Create a Raspberry Pi object
r=raspi();
img = imread('image.png');
displayImage(r,img);
end
What am I doing wrong? Am I misunderstanding the function of 'displayImage'?
Thank you!

3 Comments

Hello Karen,
displayImage function when used in "simulation", ie, just click run button in MATLAB, displays the image on host PC.
It displays the image on raspberry pi only if the function is "deployed" to the board.
Just wanted to confirm if you have followed the steps as highlighted in the below doc page for generating and deploying code from matlab functions to raspberry pi.
Please see:
Additionally, you may want to explore the below example as well.
Thanks,
Prasanth
Hi Prasanth,
Thanks for your response. I am able to successfully deploy the 'BlinkLED' function from the first example to my pi. Unfortunately I don't have a camera to actually work through the second example.
When I try to use 'deploy' function with 'ImageDisplayTest()' I get the error seen in the attached picture. The image I'm trying to display is a png I got from the internet that's stored in the same folder as my script. In your second example 'displayImage' is used to display an image that comes from the Raspberry Pi camera. Could it be an issue that I'm trying to display a picture from the web rather than something the pi processsed?
MATLAB error.PNG
Hello Karen,
Thanks for the clarification.
There are a couple of observations from my side.
1) imread is not codegen supported.
2) Trying to display an image stored from your host pc on pi is not supported. That is why you are seeing those errors.
3) However if the image is orginated from your pi through webcam or cameraboard, it possible to display that live image using "displayImage". I see that currently you do not have any image acquisition devices.
If you could share more details on the motivation to display a static image from PC on Pi, probably we could explore some other options.
-Prasanth

Sign in to comment.

Answers (0)

Asked:

on 29 Jan 2020

Commented:

on 29 Jan 2020

Community Treasure Hunt

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

Start Hunting!