Effacer les filtres
Effacer les filtres

Can I use displayImage() to display a file stored on the Raspberry Pi?

9 vues (au cours des 30 derniers jours)
Sofia Saderholm
Sofia Saderholm le 15 Fév 2022
I'm trying to write a Matlab executable that displays an image stored on the Raspberry Pi on the Pi screen/HDMI output. The code successfully generates and deploys, but when I run the .elf file, it does not bring up any display windows on the Pi (unlike with the edge detection example, which works fine.) The title tab "SDL Video Display" followed by "Raspberry Pi Display" shows up, but as far as I can tell there's no actual window associated with either.
Here's my code. There's not much too it. I have several images I want to loop through and display in full screen, but cut it down to one image & no fullscreen settings for the purpose of this post. The images are stored in the /home/pi/Ip_mat/ folder on the Pi.
function takepic() %#codegen
% Set up camera and raspberry pi connection to matlab
r = raspi('192.168.2.2') % create raspberry pi object
displayImage(r,'/home/pi/Ip_mat/Ipf1p0.png'); % display on Raspberry Pi screen
pause(2) % show for 2 seconds
end
end
Does displayImage() even support file formats that aren't directly generated from the camera or webcam objects? If not, is there any way to make a Matlab executable that displays a static image on the Raspberry Pi hardware? I'm looking into the SImulink hardware support package next, but would prefer not to use it if possible.
I'm using Matlab 2020b and a Raspberry Pi 3 running the Raspberry Pi Legacy OS.
Thanks!

Réponses (1)

Sachin Lodhi
Sachin Lodhi le 10 Nov 2023
Hi Sophia,
Based on my understanding, it seems that you want to know if ‘displayImage’ function supports file formats other than that generated by camera or webcam objects.
Indeed, ‘displayImage’ function in MATLAB supports image files that are not directly generated from the camera or webcam objects. It is capable of displaying any image file that MATLAB can interpret as a matrix of pixel values.
In this context, you can use the ‘imread’ function to read an image file into MATLAB as a matrix, and then pass this matrix to ‘displayImage’ function. Here is an illustrative example:
% Read the image file into MATLAB
img = imread('your_image_file.png');
% Display the image
displayImage(img);
Please refer to the following example for additional information related to ‘imread’ function - https://www.mathworks.com/help/matlab/ref/imread.html
I hope this helps.
Best Regards,
Sachin

Catégories

En savoir plus sur Raspberry Pi Hardware dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by