Detect People with Raspberry Pi and MATLAB Online
Learn how to use your Raspberry Pi™ with MATLAB Online™ to detect upright people. Remotely access your Raspberry Pi from anywhere that has an Internet connection. Connect to your Raspberry Pi camera module and use the
peopleDetectorACF and the
detect() method to return bounding boxes and scores for the people detected in the live video.
Download the code used in this video.
In this demo, I will show you how to detect people from a Pi camera using a Raspberry Pi™ and MATLAB Online™.
If you haven’t set up your Raspberry Pi in MATLAB Online, please refer to the documentation to learn how.
Use the command raspilist to see the online Raspberry Pis. You need to connect to your board using the function raspi(). You can either specify a Raspberry Pi or use the default which connects to the most recent board.
Here, I’m using a Raspberry Pi camera Module V2, which is connected to the Pi using the ribbon cable. Connect to it by using the function cameraboard(). Here, I’m using the resolution 640 by 480.
Next, you can load the people detector. This detector was trained using a person data set. It detects upright people using aggregate channel features.
Here you can use a for loop to repeatedly take images using the snapshot() function, and use the detect() function to find the people in the image and store the results as bounding boxes and scores.
Now, you can insert these results into the image using insertObjectAnnotation() and then use imshow() to display the image to the screen.
Click Run and a figure on the right will show up.
As you can see, as people walk into frame, they are highlighted by the yellow bounding boxes along with a score at the top of the box.
We’ve successfully detected people from the Raspberry Pi camera using MATLAB Online.
For more information, please visit the documentation at mathworks.com.
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: .
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.
- América Latina (Español)
- Canada (English)
- United States (English)
- 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)
- United Kingdom (English)
- Australia (English)
- India (English)
- New Zealand (English)
- 日本Japanese (日本語)
- 한국Korean (한국어)