#AI – Getting started with #ComputerVision, #DeepLearning, and #OpenCV by Adrian Rosebrock @pyimagesearch

display face landmarks in python using face recognition
display face landmarks in python using face recognition
Buy Me A Coffee

Hi!

When you start to research the amazing world of Computer Vision, you find that there are plenty of courses, tutorials, videos and more resources. Something is kind of “too much”, and it’s not easy to choose where to start.

That’s why, when you arrive to one of the Adrian Rosebrock tutorials or articles, they’ll end in one of your favorites bookmarks. He has amazing detailed step by step tutorials, and I learned a lot of Raspberry Pi and OpenCV from his website.

A couple of weeks ago, Adrian released an amazing resource for Computer Vision enthusiasts:

Need help getting started with Computer Vision, Deep Learning, and OpenCV?

No matter if you are starting from zero, have some knowledge or you are already an expert; you must look at this amazing compile of resources. I’ll copy and paste the main topics

And I can’t thanks enough Adrian for his amazing work and also, for sharing all of this!

Happy coding!

Greetings @ Toronto

El Bruno

Advertisements

#Event – Materials and Resources used during my #CustomVision and #AI session at #CDC2019

Hi!

Drafting these in the airplane, and also drafting a bigger post about the full and amazing experience at the Caribbean Developer Conference. So, I’ll start with the usual slides and materials, and also use this post later as reference for the full experience

Slides

Code

https://github.com/elbruno/events/tree/master/2019%2010%2004%20CDC

Links

Tweets

Greetings @ Toronto

El Bruno

References

My posts on Raspberry Pi

#RaspberryPi – Double Commander on #RaspberryPi4, because files are important!

Buy Me A Coffee

Hi !

As a Windows User, I was never happy with the out-of-the-box File Explorer, that’s why I’m a big fan of Total Commander. The 2 panels mode to move or copy files between the panels, or the quick access keys, ftp connections and more, makes Total Commander a #MustHave tool in my Windows 10 Station.

I started to look for something similar for Raspberry Pi, and after a couple of tests my choose is: Double Commander (see references).

It’s easy to install, just this command

sudo apt-get install doublecmd-qt

And it will appear on the Accessories menu.

So far, Double Commander, is part of my setup list of tools to be installed on Raspbian for my Raspberry Pi 4 developer station!

Happy Coding!

Greetings @ Burlington

El Bruno

References

My posts on El Bruno

#VSCode – Installing Visual Studio Code @code in a #RaspberryPi, run as root, fix black screen (Updated)

Buy Me A Coffee

Hi!

Now that I have my amazing Raspberry Pi 4 with 4GB RAM, it’s time to see how serious the device is. So, I decided to install and use some developers’ tools in the RPi. My dev list will be something like this

  • Python
  • Some ML and AI Python packages
  • GIT
  • Arduino
  • Visual Studio Code

It’s been a while since I installed VSCode in the device. The last time I did this, I needed to download the code from GitHub and compile the tool in the Raspberry Pi. As far as I remember this was a +25 min process.

Lucky for us the process can now be much simpler, thanks to Headmelted (see references). Now, we only need a single command to install VSCode:

. <( wget -O -
https://code.headmelted.com/installers/apt.sh )

Install process started! Or Maybe not because I found this amazing GPG error

python error installing visual studio code in raspberry pi
pi@rpidev3:~ $ curl -L https://code.headmelted.com/installers/apt.sh | sudo bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2349 0 2349 0 0 19739 0 --:--:-- --:--:-- --:--:-- 19906
Detecting architecture…
Ensuring curl is installed
Reading package lists… Done
Building dependency tree
Reading state information… Done
curl is already the newest version (7.64.0-4).
The following packages were automatically installed and are no longer required:
python3-pyperclip python3-thonny rpi.gpio-common
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Architecture detected as armv7l…
Retrieving GPG key headmelted
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
gpg: no valid OpenPGP data found.
Removing any previous entry to headmelted repository
Installing [headmelted] repository…
Updating APT cache…
Hit:1 http://raspbian.raspberrypi.org/raspbian buster InRelease
Hit:2 http://archive.raspberrypi.org/debian buster InRelease
Get:3 https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease [23.4 kB]
Err:3 https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0CC3FD642696BFC8
Reading package lists…
W: GPG error: https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 0CC3FD642696BFC8
E: The repository 'https://packagecloud.io/headmelted/codebuilds/debian stretch InRelease' is not signed.
Done!
Repository install complete.
Installing Visual Studio Code from [stretch]…
Reading package lists… Done
E: The value 'stretch' is invalid for APT::Default-Release as such a release is not available in the sources
Visual Studio Code install failed.

There a public GPG key used to verify the package and the SH script somehow does not download it (I think the ARM RPI version is still not defined). So, before the previous command, I need to run this command

wget https://packagecloud.io/headmelted/codebuilds/gpgkey -O
- | sudo apt-key add –

Then run this command

curl -L https://code.headmelted.com/installers/apt.sh | sudo bash

Now we have Visual Studio Code installed!

raspberry pi visual studio code installed

But, yes another but, you may note that the tool open and display a black window. Again, I need to go deeper on the details, but the latest version does not work well. There is some context information on GitHub (see references), and the proposed solution is to rollback to a previous version

sudo apt-get install code-oss=1.29.0-1539702286

And we also need to disable the automatic updates on this tool

sudo apt-mark hold code-oss

The following command will remove the hold for Visual Studio Code

sudo apt-mark unhold code-oss

And now, yes, we got a fully functional Visual Studio Code in our Raspberry Pi!

Another update, is a command to run VSCode as root

# open VSCode in default source code folder with root
sudo code-oss --user-data-dir=/home/pi/src/vsCodeUsrData

Of course this is not the best way to use VSCode, however something it helps 😀

Note: Due some Deep Neural Network and docker process, my device is starting to heat a lot, so I’ll try a next generation cooler like this one: Blink Blink ICE Tower CPU Cooling Fan for Raspberry Pi (Support Pi 4)

Happy Coding!

Greetings @ Toronto

El Bruno

References

My posts on El Bruno

#RaspberryPi – 6 commands to install #OpenCV for #Python in #RaspberryPi4

Hi !

Quick post to remind me the 6 commands to install OpenCV in my Raspberry Pi

sudo apt-get install libhdf5-dev libhdf5-serial-dev libhdf5-100 
sudo apt-get install libqtgui4 libqtwebkit4 libqt4-test
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
sudo pip3 install opencv-contrib-python

There is an optional command to update pip, which is always nice.

Happy Coding!

Greetings @ Burlington

El Bruno

References

My posts on El Bruno

#RaspberryPi – MultiMonitor support in #RaspberryPi4 rocks!

Buy Me A Coffee

Hi !

Another post in my path to use a Raspberry Pi 4 as a fully development device. And today, no code at all, just a showcase of the amazing new hardware: 2 video output. So let’s start with a working mode:

raspberry pi 4 multi monitor support with htop

In the previous image, in Screen 1 I’m using an instance of Visual Studio Code to do some Machine Learning with Python, and in Screen 2, I’m also browsing the history of one repo (I broke something …. as usual!).

In Screen 1, I also have Htop running, and it shows that I’m only using +780MBs of ram, that’s mean I still got 3GBs to use!

As a Windows user, I really appreciate that we had an visual interface to configure screen settings.

Raspberry Start > Preferences > Screen Configuration
raspberry pi 4 screen configuration

The [Screen Layout Editor] allows us to configure the following settings for HDMI 1 and HDMI 2 screens:

  • Resolution
  • Frequency
  • Orientation

As you can see in the following image, I got connected a HD monitor in HDMI 1 so my maximum available resolution is 1920×1080.

raspberry pi 4 screen configuration screens resolution

I haven’t connected a 4K monitor to the device, but I’ll get there 😀

Finally, you can also manage some additional screen configuration from the [Desktop Preferences] settings. I this section you can configure individual wall papers, icons to be displayed and more.

And this is also the section where you can DUPLICATE THE MONITORS ! [Show identical desktop on second monitor].

And, of course, I my demo device is ready for Caribbean Developer Conference 2019!

raspberry pi 4 multi monitor ready for Caribbean Developers Conference

Happy Coding!

Greetings @ Burlington

El Bruno

References

My posts on El Bruno

#RaspberryPi – How To automatically connect to WiFi, enable SSH on 1st boot, SSH connect and update!

Buy Me A Coffee

Hi!

If you been playing around with Raspberry Pi, I’m sure you already know this. For me this was a 1st timer, so I must write this down for the future myself.

When I started testing the Raspberry Pi 4, I got one of the complete kits, so I got the official red keyboard and mouse.

raspberry pi 4 official keyboard and mouse

I figure out I also need a couple of extra video cables. Now we need a [Micro HDMI to HDMI Cable] to connect one of the 2 video outputs to an external monitor.

This is the (cheap) monitor I’ve been using for a long time, however by default the RPi does works in a valid resolution for this monitor.

raspberry pi 7 inches monitor

And, the 2 main tasks you perform when you start your RPI are

  • Configure Wireless Connection
  • Enable SSH

Of course, you can do this directly in the SD with the Raspbian image (see references). And it’s also very easy to do.

You need to create a file named [wpa_supplicant.conf] in the root of the SD card with the following information:

country=ca
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
 scan_ssid=1
 ssid=" Your WiFi SSID"
 psk="You amazing password"
}

The file content is very straight forward to understand. Main values to complete are [ssid] and [psk]

Important: This only works the first time you boot the Raspberry Pi with the SD card. The SO search for [wpa_supplicant.conf] and performs the connection. If you already booted the device, you need to create a bootable SD card again.

If you also want to enable SSH, you need to create a blank file named [ssh] to the main partition.

And that’s it, your Raspberry Pi will be connected to the Wifi and with SSH enabled. At this moment we can use a tool like AngryIp (see references) to detect the new device in the network

My new device IP is: 10.184.1.231, so now I can use any SSH client (like Putty, see references) to connect to the device. As usual the default credentials are

  • user: pi
  • password: raspberry

You can now start working with your Raspberry Pi !

Of course, at this moment you should change your default password and update everything with a command like this one

sudo -- sh -c 'apt-get update; apt-get upgrade -y; apt-get dist-upgrade -y; apt-get autoremove -y; apt-get autoclean -y'

Happy coding!

Greetings @ Toronto

El Bruno

References

#RaspberryPi – Putting all together to display device temperature using #AzureIoT and #docker. Privilege permissions and other lessons learned

Hi!

Today challenge was based on an easy one

How do I get a Raspberry Pi temperature using Python?

The lines to do this are quite simple, with the following lines we can get the absolute value for the device temperature, in Celsius (of course!)

Easy! My next step was to add a new [Device Property] to my [Device Template] in Azure IoT. I’ll store this as a temp string, so this is fine.

azure iot device template for raspberry pi with the temperature as device property

The lines to send the temperature as a device property are part of the following code sample. I also track the temperature as telemetry so I can work with the history of the device temp

So far, so good!

Now it was time to package all this in a docker image and run it from a container. I got an ugly surprise when I realize that I got an exception trying to get the device temperature

VCHI Initialization failed

Time to read and learn more about docker and containers on Raspberry Pi.

In the official documentation of [Docker Run, see references] I found a couple of options which may help me. There are 2 options to allow me access to the device temperature

  • Run the container with the specific path to the device I want to grant privileged access for my container
  • Run the container with the [–privileged] argument to enable access to all devices on the host

Of course, the 2nd one is easier, but much more dangerous

When the operator executes docker run –privileged, Docker will enable access to all devices on the host as well as set some configuration in AppArmor or SELinux to allow the container nearly all the same access to the host as processes running outside containers on the host. Additional information about running with –privileged is available on the Docker Blog.

I didn’t think twice and run my image with the [–privileged] argument.

sudo docker run --privileged -p 80:80 <Image ID>

And now I can get an amazing history and track of information using docker, containers and Azure IoT with a Raspberry Pi

azure iot dashboard displaying temperature history as a telemetry

Happy coding!

References

#RaspberryPi – Where is my Task Manager? let’s try #htop

Hi !

As a Windows user, I use task manager a lot. You know that moment when

  1. Your PC start to work very slow
  2. You press CTRL+SHIFT+ESC to open Task Manager
  3. Select the not amicable process
  4. And Kill it !

Bonus: another group of people uses a more classic way

  1. Press CTRL+ALT+DEL
  2. Select Task Manager

These days where I’m doing part of my developer work in a Raspberry Pi 4 (see references), I was also in the need for a “Task Manager”. So a quick Bing/Google search pointed a couple of products, and htop seems to be a very popular one. And I also like the official product description

This is htop, an interactive process viewer for Unix systems. It is a text-mode application (for console or X terminals) and requires ncurses.

Official htop page (see references)

It seems that initially the product was created for Unix, and now supports FreeBSD, OpenBSD, macOS, and more. And, of course, it runs on Raspbian.

Question: Should I write a post on how to install Raspbian for Raspberry Pi? My guess is no, there are so many of this already out, but ... if get bored.

Before I move on, let’s take a look at htop running in my device, while I’m building a docker image using some amazing TensorFlow image analysis models.

The way to install htop is very straightforward.

sudo apt-get install htop

Then you can launch the app with

htop

Super Easy ! And again, the UI gives you a lot of very useful information, and because Linux users are heavy on commands and not mouse, 99% of the actions to control the app are using these commands

  • F1 – Help (explains everything, always nice)
  • F6 – SortBy (You can sort the list processes with this option. Sorting by user, CPU usage and memory usage can be useful.)
  • F9 – Kill (You can select a process and send a kill signal)
  • F10 – Quit (sometimes you gotta leave htop)
Note: Get the commands and learn from David Walz post (see references)

Happy Coding!

Greetings @ Burlington

El Bruno

References

#Azure – Sending custom Telemetry and Event information from a #RaspberryPi device to #AzureIoT Central

Hi!

Azure IoT Central is one of the amazing services we can use on Azure. I was wondering how easy is to use a Raspberry Pi using Raspbian and Azure IoT and here is my experience.

Let’s assume we had a device up to date using Raspbian, our next step will be to create an Azure IoT Central application. The official step by step is the main resource for this

Create an
Azure IoT Central application (see references)

Once we have our application, we can quickly create a new Raspberry Pi device and use it. However, I’ll do an extra step, lessons learned as a handsome developer

Create a Device Template

Go to [Device Templates] and create a new template

azure iot central create new device template

For Raspberry Pi, I’ll name this [Raspberry Pi Dev]

azure iot central create new device template raspberry pi dev

So now, I can add a new real device, in the Devices section from the left menu

azure iot central raspberry pi dev add new real device

Once you create a new real device, is important to copy and save for later the connection information. To access this, go to the top right [Connect] button

azure iot central raspberry pi dev real device connect information

Almost there, there is an official tutorial that explain how to send random telemetry information with a Python script in a Raspberry Pi. I’ll use it as base for this scenario.

Connect a
Raspberry Pi to your Azure IoT Central application (Python) (see references)

For this demo, I’ll add a custom telemetry property and a custom event to the device. Since I won’t use the device to track temperature, accelerometer, and more, I think it make sense to track some custom information.

So, I’ll go back to my Device Template definition and I’ll add a new Telemetry, named [t1], with the following information.

azure iot central raspberry pi dev new telemetry information

And now, I can run a custom version of my script that will send new telemetry information, for [t1]. Sample in line 18

After a couple of minutes running the sample script, I can see the telemetry information for T1. In this view, I enabled [Temperature] and [T1] to display the timeline.

azure iot central raspberry pi dev real device dashboard telemetry

And, next step will be to add an event, which is also a very important uses case in Azure IoT. Back in the Device Template, I add a new event named [event1]

azure iot central raspberry pi dev new event information

And added some extra lines of code to send also an event between telemetry, Line 22

In the following image, we can see how the events appears in the timeline, and we can also get some extra details clicking on each event.

azure iot central raspberry pi dev real device dashboard telemetry and events

Very cool! Next steps will be to integrate this with some image recognition scenarios.

Happy Coding!

Greetings @ Burlington

El Bruno

References