#Python –Detecting #Hololens in realtime in webcam feed using #ImageAI and #OpenCV (thanks to @OlafenwaMoses)

Hi!

Let’s start with a very quick intro:

During the past months, I’ve been playing around with several Image Analysis tools. And ImageAI (see references) is one that deserves a full series of posts. Please take a look at the product and the source code in GitHub, and also please thank the one behind this: Moses Olafenwa (@OlafenwaMoses).

And now, my 2 cents. I’ve started to test ImageAI to create my own image detection models. Most of the times, this is a hard path to do, however ImageAI show me an interesting option.

… with the latest release of ImageAI v2.1.0, support for training your custom YOLOv3 models to detect literally any kind and number of objects is now fully supported, …

Wow! That’s mean that I can pick up my own set of images dataset and train on top of a YOLOv3 and use it as a trained model. Again, this is amazing.

So, I started to read the article [Train Object Detection AI with 6 lines of code, see references] where Olafenwa explains how to do this using a data set with almost 500 rows with images for Hololens and Oculus Rift.

The code is very simple and easy to read. There are also examples on how to analyze a single file, or a video, or even a camera feed. The output for the analysis can be also in a new file, in a processed video or even a full log file with the detected information.

I started to read the code samples and I realized that I’m missing a scenario:

Display the realtime feed from a webcam, analyze each webcam frame and if a device is found, add a frame to the realtime feed to display this.

I use OpenCV to access to my camera, and it took me some time to figure out how to convert my OpenCV2 camera frame to the format needed by ImageAI. At the end, thanks to the GitHub code I manage to create this (very slow but working) demo

As usual in this scenario, now it’s time to improve the performance and start testing with some tweaks to get a decent up and running App.

And of course, the code

Happy coding!

Greetings @ Toronto

El Bruno

Resources

Advertisements

#Humor – Constants are not constants, sure? Oh yeah, because #JavaScript … Of course

Greetings @ Burlington

El Bruno

#AI – Introduction to #deeplearning vs. #machinelearning by @frlazzeri. The best 10 min read for today

Hi!

Explain the differences / relationship between Machine Learning and Deep Learning is a question that I face in every event or chat about Machine Learning.

And I used to have my 5 bullets explanation for this. However, now thanks to Francesca Lazzeri (@frlazzeri) I can advice people to read this amazing article.

Introduction to deep learning vs. machine learning

Introduction to deep learning vs. machine learning

So, you know, if you have 10 minutes, this will really help you understand the relationships between AI, ML and DL!

Happy Coding!

Greetings @ Toronto

El Bruno

#VSCode- Add #AzureIoT source files to your C++ settings in #VisualStudioCode

Hi!

Context: You may call me picky, but I like to read source code. And if I know that I have the source code, but I can reach it, I can’t code in happy mode.

So, I’m back to Azure IoT and while I was browsing the Project Catalog for my DevKit device. I hold myself in the [Get Started – Connect IoT DevKit AZ3166 to Azure IoT Hub] section thanks to this warning.

visual studio code mxchip get started cant find include errors

Don’t get me wrong, once you installed Visual Studio Code, Arduino and the complete set of dependencies; you can build and deploy everything. However, I need my peek definition and the following error is a stopper for me

visual studio code include file not found in browse.path
Error: Visual studio code include file not found in browse.path 

The main problem is that the C++ extension can’t found any of the Azure IoT files. So, we need to add the path to VSCode settings. Lucky for us, the tip bulb will directly guide us to this option

visual studio code edit browse path setting

We only need to add this path to the C++ settings. Of course, check your Arduino version and your username

C:\Users\{user name}\AppData\Local\Arduino15\packages\AZ3166\**

And that’s it! Peek definition and more is available now

visual studio code c++ peek definition

Happy coding!

Greetings @ Burlington

El Bruno

Resources

#Microsoft – Insider Programs at Microsoft (thanks to @shanselman!)

Hi!

3 years ago, I wrote a post where I listed some of the Insider Programs at Microsoft.

Microsoft – List of almost all #Insider Programs (the ones I know …)

This was on 2016 November, and I added in the list Windows Insider, Office Insider, Visual Studio Insider, the almost dead Skype Insider and more.

Now thanks to Scott Hanselman (@shanselman) I found an official resource with all the Insider Programs at Microsoft.

Insider Programs at Microsoft

Up to today, we can find Bing, Edge, Office, Skype (still!), Visual Studio, Visual Studio Code, Windows and Xbox. Super cool!

Happy coding!

Greetings @ Burlington

El Bruno

#RaspberryPi – Running a #python script in a Python Virtual Environment on reboot / startup

Hi!

Adrian Rosebrock is a very smart person who has tons of great resources about Computer Vision in PyImageSearch.com. Most of them are with Python, and he also have some of them focused on how to perform CV using OpenCV in a Raspberry Pi.

In the post [Running a Python + OpenCV script on reboot, see resources] he explains how to automatically run a Python script when a Raspberry Pi starts. He uses python virtual environments, so the first 2 commands are focused on to load the virtual env. Then, move to the app folder and run the python script.

source ~/.profile
workon cv
cd /home/pi/pi-face-recognition
python startup.py

Something like this:

python source and cv on raspberry pi.

The suggested approach consists on create a Schell Script [.sh file] with these lines and add them to the auto start. However, once you create the file and test it, there seems to be an issue with the Source command.

python source not working on SH file

Ok, so no source command in an SH file. I started to think on install all my python dependencies directly in the main user, however the idea of working with virtual environments is very useful for me. It was to read online about Linux, python and more.

Note: Before moving forward, I may need to add some context. I need to run my python script in a Terminal. My device will always auto-start with a 3.5 inches touch screen and a camera, so I need some GUI loaded.

This is an excellent article on how to add actions to the Raspberry Pi start-up [How to Execute a Script at Startup on the Raspberry Pi, see resources]. So I added my SH file here and it didn’t work and I need to figure out how to load a virtual environment and run a python script.

After a couple of tests, I realized that all the files I need are part of the virtual env location in the device.

raspberry pi python folder for virtual envs

So, I only need to add the full path to my command to make it work without the and [workon] command. My complete command will became:

/home/pi/.virtualenvs/cv/bin/python /home/pi/pi-face-recognition/startup.py

So, I edited my autostart file adding this command

raspberry pi auto start file launching python script with a virtual env

And done! My python script running on a python virtual environment on the device startup is working!

Happy coding!

Greetings @ Toronto

El Bruno

Resources

#Event – I’ll be at the Caribbean Developer Conference on October ! #CDC2019

Hi !

Wow, I’ll completely amazed because I’ll have the chance to share some Machine Learning, Custom Vision and other experiences in the Caribbean Developer Conference in October.

Caribbean Developer Conference

This event is great and as usual, the list of speakers is AMAZING!

I’ll share more details later, and in the meantime, if you want to know more, the 2018 video recap is a great way to

Happy Coding!

Greetings @ Toronto

El Bruno

#Python – How to create a Virtual Environment in #Windows10 (Easy one, and brain backup!)

Hi!

Quick post today, and mostly a reminder on how to create a Virtual Environment in Python in Windows 10. I’ve been doing this mostly in my Mac and my Raspberry Pi, and I always forget how to do this on Windows, so … I’ll write this post to have this

Install Python3.

Download the installers from the official Python source (see references). I usually install it on the root of my C: hard drive and name it with the version. In example: c:\Python37_64 folder.

Remember to also add this folder and the Scripts folder to the Environment Variables.

Note: Once you start to install tools which uses Python, your OS becomes a nightmare. You will have your own installed python, the version installed with Visual Studio, the one with Visual Studio Code, another one for Anaconda.

I’m not sure if this is a best practice or not, but I usually remove all the other versions and keep mines in the root of the C: drive.

Ok, let’s go on.

For a new virtual environment named “testEnv”, open a command prompt and navigate to the python folder. Then run the command

python -m virtualenv testEnv

After a couple of seconds, the virtual Environment will be installed, and you can use it by run the [activate.bat] script. In this example

  • The virtual environment will be created at [c:\Python37_64\testEnv]
  • The virtual environment activate script will be at [c:\Python37_64\testEnv\Scripts\activate.bat]

So the full command sequence is similar to this one

Now you have your virtual environment up and running and you may want to start to add your own packages or tools. Like in example: Numpy or to list the installed packages

Finally, you may leave the virtual environment with the command

deactivate

Happy Coding!

Greetings @ Toronto

El Bruno

Resources

#Podcast – #MVPbuzz Chat Episode 33 with Bruno Capuano @collabtalk

Photo by Matheus Bertelli on Pexels.com

Hi!

Some time ago, I was lucky enough to share sometime with CollabTalk Founder & CEO Christian Buckley (@buckleyplanet) in his virtual meeting space.

We had an amazing chat about the current (at that time) state of Artificial Intelligence, some chats about Microsoft technologies and more.

Now all the episodes of CollabTalk episodes are also available in podcast mode here. You can found +35 episodes with some really cool and amazing people, and in the episode 33, somehow I make the list.

The complete list is available here https://soundcloud.com/collabtalk

And my episode is here (link)

Happy coding!

Greetings @ Burlington

El Bruno