MathWorks - Mobile View
  • Accedere al proprio MathWorks AccountAccedere al proprio MathWorks Account
  • Access your MathWorks Account
    • Il Mio Account
    • Il mio Profilo utente
    • Associa Licenza
    • Disconnettiti
  • Prodotti
  • Soluzioni
  • Università
  • Assistenza
  • Community
  • Eventi
  • Acquista MATLAB
MathWorks
  • Prodotti
  • Soluzioni
  • Università
  • Assistenza
  • Community
  • Eventi
  • Acquista MATLAB
  • Accedere al proprio MathWorks AccountAccedere al proprio MathWorks Account
  • Access your MathWorks Account
    • Il Mio Account
    • Il mio Profilo utente
    • Associa Licenza
    • Disconnettiti

Video e Webinar

  • MathWorks
  • Video
  • Home Video
  • Cerca
  • Home Video
  • Cerca
  • Contattaci
  • Software di prova
  Register to watch video
  • Description
  • Full Transcript
  • Related Resources

Raspberry Pi Support from MATLAB, Part 3: Deploy an Edge Detection Algorithm on Raspberry Pi

From the series: Raspberry Pi Support from MATLAB

Meeshawn Marathe, MathWorks

Learn how to develop and prototype an Edge Detection algorithm within MATLAB®, and then deploy to the Raspberry Pi hardware using MATLAB® Support Package for Raspberry Pi™ and MATLAB Coder™.

In this video, we'll take a look at deploying an edge detection algorithm to the Raspberry Pi hardware. We will be performing edge detection on light images captured from the webcam, which is a peripheral device connected to the Raspberry Pi hardware through USB. The image feed along with the highlighted edges will be displayed in MATLAB during the connected I/O workflow since the MATLAB function runs in MATLAB.

This will be followed by hardware deployment, wherein the edge detection algorithm will now execute on the hardware independent of MATLAB. The video feed with the highlighted edges will be displayed on Raspberry Pi. We will be remotely connecting to the Raspberry Pi hardware using VNC Viewer to view the live video output. Gain access to the edge detection example discussed in this video by searching in the documentation doc edge detection Raspberry Pi.

This document explains the step-by-step implementation of the algorithm. I recommend going through the link, since we will not be discussing the algorithm in complete detail. Briefly speaking, the MATLAB function captures images over an interval, applies a filter based on a 3-by-3 Sobel operator, and then performs thresholding to highlight edges within the image.

First, let's clear the workspace. Now let's run this MATLAB function. You can see the live image feed alongside the edge detector images being displayed in MATLAB. This is the connected I/O workflow, wherein the edge detection algorithm executes in MATLAB. imshow function is used to display the image feed.

Next, let's open VNC Viewer. It can be easily downloaded from the web in case you don't have it installed. The device address has already been entered previously. We can find this from the target hardware object or the Raspberry Pi object created in the workspace. The default username and password are Pi and Raspberry, respectively.

Next, we will deploy the MATLAB function for a standalone execution on the hardware, independent of MATLAB. Target object equals target hardware, Raspberry Pi, deploy, target object, edge detection.

Uh-oh, we have a problem here. As we can see here, this function, imshow, is not supported for code generation. And the coder report aptly detected this. Hence, we will need to replace it with its codegen counterpart, as discussed earlier. displayImage is the Raspberry Pi function equivalent of imshow used for deploying images on Raspberry Pi. Let's re-attempt to deploy now. Deploy target object, edge detection.

So now you are seeing a live feed from the webcam, alongside the edge-detected images, which is being displayed here on the Raspberry Pi desktop. This is the hardware deployment workflow, wherein the MATLAB function is being executed on the hardware independent of MATLAB. The executable gets generated in the Build folder set in the hardware configuration object.

This executable can also be launched as a Linux application. The exact location of the executable can be found here under the Build Directory, MATLAB workspace, R2019b, the PWD folder structure. The location under the really specific folder, which in this case is R2019b, mimics that of the actual Working Directory folder structure. Let's launch this executable from the terminal. As you can see here, the edge detection algorithm is running as a Linux application on the Raspberry Pi hardware, independent of MATLAB.

Wow, that was interesting. With this, we come to the end of this video. I hope now you'll feel more confident to get started with designing and deploying your applications to Raspberry Pi hardware from MATLAB. For more interesting videos, please visit www.MathWorks.com/videos. Thank you.

Related Products

  • MATLAB Coder

Learn More

Download MATLAB Support Package for Raspberry Pi
Edge Detection with MATLAB
Examples on Raspberry Pi Support from MATLAB
Join the Raspberry Pi File Exchange Community
Related Information
Get access to the Edge Detection example discussed in this video

Feedback

Featured Product

MATLAB Coder

  • Request Trial
  • Get Pricing

Related Videos:

4:21
Accelerate Image Compression Algorithm Using MATLAB Coder
4:34
Generating C Code from MATLAB Code
1:16:35
Embedded MATLAB Design Optimizations: C code Customization,...
4:19
Unit Testing C Code Using MATLAB and MATLAB Coder
11:24
Addressing Implementation Constraints Using MATLAB Coder

View more related videos

MathWorks - Domain Selector

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Select web site

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • Contattaci
  • Software di prova

Scopri i nostri prodotti

  • MATLAB
  • Simulink
  • Software per studenti​
  • Supporto hardware
  • File Exchange

Prova o Acquista

  • Download
  • Software di prova
  • Contattaci
  • Prezzi e licenze
  • Come acquistare

Impara ad utilizzare i nostri prodotti

  • Documentazione
  • Tutorial
  • Esempi
  • Video e Webinar
  • Formazione

Ricevi supporto tecnico

  • Aiuto all'installazione
  • Risposte​
  • Consulenza
  • License Center
  • Contatta l'assistenza

Informazioni su MathWorks

  • Lavora con noi
  • Sala stampa
  • Missione sociale​
  • Contattaci
  • Informazioni su MathWorks

MathWorks

Accelerating the pace of engineering and science

MathWorks è leader nello sviluppo di software per il calcolo matematico per ingegneri e ricercatori

Scopri…

  • Select a Web Site United States
  • Brevetti
  • Marchi
  • Informativa sulla privacy
  • Antipirateria
  • Stato dell'applicazione

© 1994-2021 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

Unisciti alla discussione

This website uses cookies to improve your user experience, personalize content and ads, and analyze website traffic.  By continuing to use this website, you consent to our use of cookies.  Please see our Privacy Policy to learn more about cookies and how to change your settings.