Elektor01 2025
Elektor01 2025
COM
D I G I TA L
534B
SI
NCE 1961
EDITION
Articles
Gue for Pros, Makers,
st-Ed and Students!
ited
Edition
Raspberry Pi AI Camera
50 A
I Ke y Terms
For Engi
neers
and Makers
AI for Product
Concept Design
A Tour of the World of
AI-Based Art Generators High-Performance
Edge AI
The New STM32N6
AI-Based Universal IR Remote Control A Personal AI Terminal Hailo AI Kit with Raspberry Pi 5
Gesture-Controlled with Raspberry Pi ChatGPT Gets a Voice Object Detection Made Easy
PE8000G
Revolutionary Edge AI performance
Robust and reliable Powerful dual GPU support
The PE8000G complies with the MIL-STD- Process multiple neural networks
810H standard and is therefore protected simultaneously thanks to the support of two
against extreme temperatures, vibrations 450-watt GPUs - seamlessly and in real time.
and voltage fluctuations - ideal for use in This allows you to complete even complex
harsh industrial environments. tasks efficiently and quickly.
Volume 50
Guest-Edited AI Digital Bonus Edition
ISSN 0932-5468 Bonus AI Projects and Articles
Elektor Magazine is published 8 times a year by Did you really think we were done delivering In “AI for Product Concept Design” we look at how
Elektor International Media b.v. AI-related content after we announced the 2024 AI has revolutionized image creation. Designers
PO Box 11, 6114 ZG Susteren, The Netherlands Guest-Edited AI edition of ElektorMag? No way! can transform sketches and ideas into photore-
Phone: +31 46 4389444 As regular Elektor readers know, we always have alistic renderings with just a well-crafted text
www.elektor.com | www.elektormagazine.com
new projects, tutorials, and background articles prompt. Dive into this exploration of AI-pow-
in the pipeline. With this Bonus edition, which ered design tools.
For all your questions
[email protected] we’ll unveil over the course of four weeks, we aim
to inspire you to design new AI-related solutions Curious about the history of AI in the pages of
Become a Member for weeks and months to come. Elektor? In this edition, we take you on a journey
www.elektormagazine.com/membership through Elektor’s archives, showcasing how
If you are looking for a project to start experi- artificial intelligence has evolved within the
Advertising & Sponsoring
menting with AI, the article, “AI-Based Universal electronics community. Dive into our editors’
Büsra Kas
IR Remote Control,” is a great place to start! With top recommendations from past editions of your
Tel. +49 (0)241 95509178
[email protected] the help of a Raspberry Pi 5, Google’s MediaPipe favorite magazine.
www.elektormagazine.com/advertising Studio platform, and a tiny plug-in interface
board, you can have a versatile gesture recog- And much more awaits you in this free Bonus
Copyright Notice nition system to control your TV or other devices edition!
© Elektor International Media b.v. 2024 operated through IR remote controls.
After you dive into this issue and start your
The circuits described in this magazine are
Can a modern build capture the spirit of Turing’s own AI-related projects, be sure to share your
for domestic and educational use only. All
drawings, photographs, printed circuit board original experiment? In “A Personal AI Terminal,” experiences on the Elektor Labs online platform:
layouts, programmed integrated circuits, discover how an ESP32 module, paired with a www.elektormagazine.com/labs. We look forward
digital data carriers, and article texts published TFT display and an I2S amplifier, becomes the to learning about your creations!
in our books and magazines (other than gateway to a 21st-century version of the Turing
third-party advertisements) are copyright Test, communicating directly with ChatGPT. C. J. Abate (Content Director, Elektor)
Elektor International Media b.v. and may not
be reproduced or transmitted in any form
or by any means, including photocopying,
scanning and recording, in whole or in part THIS EDITION
without prior written permission from the
Publisher. Such written permission must also
be obtained before any part of this publication
4 A Personal AI Terminal
is stored in a retrieval system of any nature. ChatGPT Gets a Voice
Patent protection may exist in respect of
circuits, devices, components etc. described 8 High-Performance Edge AI: The New STM32N6
in this magazine. The Publisher does not A Game-Changer in Performance and AI Capabilities
accept responsibility for failing to identify such
patent(s) or other protection. The Publisher
disclaims any responsibility for the safe and
12 Unlocking AI
proper function of reader-assembled projects 50 Key Terms for Engineers and Makers
based upon or from schematics, descriptions
or information published in or in relation with 16 Raspberry Pi AI Camera
Elektor magazine. Taking the Hassle out of the Edge
International Editor-in-Chief
Jens Nickel 22 Artificial Intelligence in Elektor
32 Infographics:
Publisher The Guest-Edited AI Edition 2024 of
Erik Jansen
Artificial Intelligence
ElektorMag is available at newsstands
and in the Elektor Store.
34 AI-Based IR Remote Control
www.elektor.com/ep-0534
Gesture-Controlled with MediaPipe
and Raspberry Pi
A Personal
AI Terminal
ChatGPT Gets a Voice
By Somnath Bera (India) You may be surprised at the use of an old PS2 keyboard; the only reason
is that I was not successful at implementing a USB port for this purpose
Whether AI solutions such as ChatGPT can on the ESP32. In the limited time available, I opted for the simpler PS2
pass the Turing test is still up for debate. type of interface, which uses far fewer resources. A PS2 socket for the
keyboard can be sourced from several web-based electronic compo-
Back in the day, Turing imagined a human nent distributors. The PS2 keyboard pin assignments can be seen in
operator judging replies to questions sent the circuit diagram. No doubt there will be developers out there itching
and received using an electromechanical to upgrade the system to USB, and I welcome their input.
teletype machine. Here we build a 21st- The 3.5-inch TFT touch display used has a parallel interface rather
century version of Turing’s original than the alternative SPI version. This inevitably uses more interconnect
experimental concept, using an ESP32 with wires, but in this application, we have enough spare GPIOs and the
interface offers a significantly faster response time. The touch screen
a keyboard and TFT display to communicate features are not used in this application.
exclusively with ChatGPT via the Internet.
In addition, Google text-to-speech together A MAX98357A I2S amplifier (Figure 2)
module takes the digital audio I2S signal
with a tiny I2S amplifier module and speaker generated by the ESP32 and converts it
lets you listen in to the conversation. In our into analog audio. A built-in, 3-W class D
case, it’s obvious from the start that we are amplifier boosts the signal to achieve a
good level of sound. The gain input is
communicating with a machine — isn’t it? tied to ground, which produces maximum
volume from the amp. The class D amp Figure 2: The audio amp
output can drive a 4-Ω speaker. module converts I2S digital
audio to 3 W of audio.
There is no doubt that AI tools such as OpenAI’s ChatGPT and Google’s
Gemini can be real game changers in so many situations. I have used Don’t Lose the Key
ChatGPT to develop quite complex control solutions. I provide the ChatGPT was developed by OpenAI. It generates text-based responses
initial idea, and as I give more inputs, it refines the code, making it to prompts or questions entered by the user. Usually, it works through
better with each iteration. It can even convert Python code to Micro- a browser interface. The OpenAI API has been designed for use by
Python or an Arduino sketch. The key is to guide the process carefully developers and businesses so that they can integrate AI features into
to prevent it from straying too far off course. There are times when their own applications, software, or websites. It’s not just a chatbot
it does deviate and repeats the same mistakes, but I actually enjoy interface, but a flexible programming interface allowing businesses
finding these bugs and steering ChatGPT’s output to more closely to embed chatGPT’s capabilities into their products. Developers send
match my target outcome. data to the API programmatically and get responses back. To use the
OpenAI API, you will need a unique key, which is generated for your
Hardware account when you sign up. Go to the OpenAI website [1] and click
The heart of this build is Espressif’s ESP32 development module. Its on the Sign up button.
dual-core architecture has enough processing reserve to take care of
Wi-Fi communications, handling the serial input from a PS2 keyboard, Fill out the registration form with your email address, password, and
sending data to the 3.5-inch TFT display and outputting digital audio other required information. Once you have entered these, navigate to
data to the I2S module. The complete schematic for the ChatGPT your OpenAI account dashboard and click on the New Project button.
terminal is shown in Figure 1. Give your project a name and description (optional). In your project
4 www.elektormagazine.com
+5V
4
2 6
PS/2-keyboard
1 5
DATA 3 IRQ ESP32-DevKitC
1 38 MAX98357A
3V3 GND
3.5 TFT 2 37
EN/RST GPIO23 LRC
+5V Touch 3 36
GPIO36/SVP GPIO22 BCLK
Screen 4 35
GPIO39/SVN GPIO1/TX0 DIN –
1 21 5 34
GPIO34 GPIO3/RX0 GAIN +
2 22 6 33
GPIO35 GPIO21 SD
3 23 7 32
GPIO32 GND GND
4 24 8 31
GPIO33 GPIO19 +5V VIN
5 25 9 30
GPIO25 GPIO18
6 26 10 29
GPIO26 GPIO5
7 27 11 28
GPIO27 GPIO17
8 28 12 27
GPIO14 GPIO16
9 29 13 26
GPIO12 GPIO4
10 30 14 25
GND GPIO0
11 31 15 24
GPIO13 GPIO2
12 32 16 23
GPIO9/SD2 GPIO15
13 33 17 22
GPIO10/SD3 GPIO8/SD1 +5V
14 34 18 21
GPIO11/SDCMD GPIO7/SD0
15 35 19 20
5V GPIO6/SDCLK 7805
16 36 3 2
17 37 EN IO0
USB
18 38 +5V
19 39 1 7...9V
20 40
100µ
10V
230536-025
settings, click on the API Keys tab. You’ll see a list of existing secret these credits, you will need to pay based on your usage. If you haven’t
keys (Figure 3). Click the Create new secret key button to generate a already set up a payment method for billing, it will be necessary to
new key. Make a copy of this generated API key and save it securely, do so. Read through OpenAI’s usage guidelines and terms of service.
as you won’t be able to retrieve it again for security reasons. You’ll need
this key to authenticate your applications with OpenAI’s services. On Text to Speech
their site there is also a developer’s quickstart tutorial which guides A Text to Speech (TTS) API is used to convert the textual response
you through the process of generating a response via the API using from OpenAI into a digital audio data stream. There are a couple of
the generated key to authorize your access. text-to-speech APIs we can use for this. OpenAI has its own TTS API
offering a number of different voice alternatives which sound quite
At the time of writing, OpenAI provides free credits when you first sign natural. To access this API, you use the same key you were allocated
up, which you can use to experiment with the API. After you use up all to use the OpenAI API.
2. Next, prepare the payload which will be JSON formatted: void setup() {
delay(300);
StaticJsonDocument<1024> jsonPayload; …
6 www.elektormagazine.com
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT); In every case, ChatGPT performed flawlessly, understood the context
//I2S board initialised perfectly and answered accurately, with the speaker delivering the
audio.setVolume(50); voice output loud and clear.
Inside the loop function, we sent questions to ChatGPT. When the To Wrap Up
session is complete we remain inside loop: All files associated with this project can be found at [2]. The Inter-
net and web browsers such as Google have totally revolutionized
String response = makeApiRequest(msg); our access to information and replaced those bulky encyclopedias
// sent to Chatgpt that used to line our bookshelves at home. Now we see the rise of AI
... software and machines based on ChatGPT API, TensorFlow Lite Micro,
if (l1>200) { Edge Impulse, OpenMV, TinyML which are poised to disrupt existing
response = response.substring(0, 200); business models and more traditional methods of problem-solving.
// truncate first 200 characters We live in interesting times.
} 230536-01
audio.connecttospeech(response.c_str(), "en");
//speak up the 200 characters
The Google TTS has a 200-character limit and will not output any text
beyond this limit. To work around this, the answer string is trimmed to
200 characters for Google TTS. This ensures that while the full answer
is displayed on the screen, only the first 200 characters are vocalized. About the Author
For longer answers, the screen scrolls, but this can be adjusted by Somnath Bera, a mechanical engineer from Jalpaiguri Govt. Engg.
making slight modifications to the sketch. College, India, worked as a General Manager at NTPC, the largest
power producer in the country. He has a profound passion for
Project Testing electronics, evidenced by his 60+ innovative projects on Elektor
The delays I’ve used inside the software loops are quite specific. You Labs, over 10 of which have been featured in ElektorMag. His
may adjust them, but I recommend starting with the default values used projects are often focused on problem-solving in areas like waste
in the code. Once you’re comfortable with the responses, feel free to and natural resource management. Somnath likes to use innovative
tweak them. I began with simple questions like “Who r u?” ChatGPT approaches and platforms like Arduino, Raspberry Pi, and ESP32
responded appropriately, displaying the introduction on the screen, coupled with various kinds of sensors and wireless systems to
while the speaker articulated it clearly. create efficient and cost-effective solutions.
I then tested the system using questions such as: “Write 5 sentences
about Elektor magazine” (Figure 4) and even asked it to write blink Questions or Comments?
sketches for Arduino UNO, ESP32, and Raspberry Pi Pico. If you have technical questions or comments about this article, feel
free to contact the author by email at [email protected] or
the Elektor editorial team at [email protected].
Related Product
> Espressif ESP32-DevKitC-32E
www.elektor.com/20518
WEB LINKS
[1] OpenAI website: https://platform.openai.com
[2] Elektor web page for this article (downloads):
Figure 4: Testing the system with prompts asking for blink sketches for https://www.elektormagazine.com/230536-01
Arduino UNO, ESP32, and Raspberry Pi Pico.
Contributed by STMicroelectronics
Figure 4: STM32Cube.
AI and ST Edge AI
Developer Cloud are
designed for users who
need great flexibility. The
comprehensive model
zoo with application
code examples is a
great starting point for
developers who want
to quickly implement AI
solutions.
a range of software tools for configuration, develop- wide range of applications, from audio processing to
ment, programming, and monitoring. For embed- computer vision. The STM32N6 empowers develop-
ded software, it includes packages, middleware, and ers to create smarter, more efficient, and more secure
driver support, complemented by RTOS options like devices that can operate at the edge.
FreeRTOS, Zephyr, and Eclipse ThreadX (Figure 7).
Developers can leverage the STM32N6 to create intel-
In the AI domain, developers have access to tools, ligent home automation systems that recognize
resources, case studies, and support from partners like and respond to various commands and situations,
Edge Impulse, Nota.AI, and EmbedUR. For graphics enhancing convenience and security. In healthcare,
development, the STM32N6 is supported by TouchGFX, this STM32 can be used to develop advanced medical
simplifying the creation of sophisticated graphical devices that monitor patient health in real-time,
user interfaces (GUIs). This extensive support network providing accurate diagnostics and timely alerts.
ensures that developers have the assistance they need For industrial automation, the STM32N6 enables
at every stage of the development process, enabling the design of robust systems that perform complex
the creation of visually stunning and highly respon- tasks with high precision and efficiency, improving
sive applications. productivity and safety. In the consumer electron-
ics space, this microcontroller allows for the innova-
Flexibility and Versatility tion of new gadgets that offer enhanced multimedia
With its rich peripheral set and extensive connectivity experiences, from high-definition video playback to
options, the STM32N6 offers developers the flexibility immersive gaming.
to design a wide range of applications. Whether it’s
computer vision, audio processing, or advanced multi- The STM32N6 is a testament to STMicroelectron-
media, the STM32N6 provides the necessary tools and ics’ commitment to innovation and excellence. By
capabilities to bring innovative ideas to life. Addition- redefining microcontroller performance and integrat-
ally, the STM32N6 will also be available in a version ing advanced AI capabilities, the STM32N6 empow-
without the NPU for applications requiring high-per- ers developers to create cutting-edge applications
formance computing, graphics, and multimedia but that stand out in the competitive market. With its
not demanding AI features. This versatility ensures seamless integration into the STM32 ecosystem and
that developers can choose the right configuration for support from numerous partners, the STM32N6 is
their specific needs, making the STM32N6 suitable for poised to revolutionize the world of microcontrollers
a variety of industries, including automotive, health- and embedded AI.
care, consumer electronics, and industrial automation.
For more information, visit www.st.com/stm32n6.
Exciting Possibilities for Developers 240676-01
The STM32N6 opens up new horizons for embedded AI
applications, offering unmatched edge AI performance
on an MCU. Its small footprint, lower power consump-
tion, and reduced costs make it an ideal choice for a
Unlocking AI
50 Key Terms
for Engineers
and Makers
Artificial Intelligence (AI)
The simulation of human intelligence
in machines programmed to think,
learn, and solve problems. It’s a
broad field that encompasses a wide
By The Elektor Team
range of technologies and applica-
Activation Function tions, including simple algorithms,
AI is reshaping the world A function in neural networks that chatbots, neural networks, and
of electrical engineering determines the output of a neuron, complex self-driving cars.
and DIY projects. helping to introduce nonlinearity.
The choice of activation function
But which terms are can significantly impact the
Backpropagation
A neural network training method
essential to know? We network’s performance and learning
that adjusts weights by propagat-
asked AI (e.g., ChatGPT capabilities.
ing the error backward from the
and Gemini) — and the output layer to minimize the differ-
Algorithm ence between predicted and actual
answers might surprise A step-by-step computational outputs. It updates weights based
you! These terms provide procedure for solving a problem or on the error rate from previous
a solid foundation performing a task. Think of it as a iterations.
guide that outlines the specific steps
for understanding AI a computer or person should take to
concepts relevant to Bias
achieve a specific goal.
An adjustable parameter in machine
electrical engineering learning models that allows for shift-
and making. Artificial General ing the activation function, influenc-
Intelligence (AGI) ing model predictions. Bias is an
Hypothetical AI capable of under- important concept in machine learn-
standing, learning, and performing ing, as it can help to improve the
any intellectual task like a human. accuracy and flexibility of models.
While AGI remains a theoret- However, bias can introduce system-
ical concept, researchers are atic errors into a model’s predictions.
actively working on developing AI
systems that exhibit some of these
capabilities.
12 www.elektormagazine.com
Edge AI
Big Data AI computation and processing
Massive datasets that can be done locally on edge devices rather
analyzed computationally to reveal than centralized cloud servers.
patterns, trends, and associations. Data Mining This approach can reduce latency,
Big Data is commonly used in fields The process of discovering patterns enhance privacy, and minimize
like scientific research and IoT and extracting useful informa- bandwidth use, making it a smart
applications to make data-driven tion from large datasets. It involves solution for real-time applica-
decisions, predict outcomes, and methods such as classification, tions like autonomous vehicles and
optimize processes. clustering, and association rule learn- augmented reality.
ing to transform raw data into action-
able insights for decision-making. Epoch
Classification
A supervised learning task of assign- One complete cycle through the
ing input data to one of several Data Preprocessing full training dataset during machine
predefined categories or labels. The The steps taken to clean, transform, learning model training. Multiple
objective is to build a model that and prepare raw data for machine epochs are often required to ensure
accurately predicts the category of learning models. This includes that the model has learned the data’s
new, unseen data based on patterns handling missing values, normaliz- underlying patterns adequately.
learned from labeled training data. ing data, and encoding categorical
variables, which are crucial for ensur- Feature Engineering
ing accurate model performance.
Clustering The process of selecting, modify-
An unsupervised learning technique ing, or developing new features
that groups data points with similar Deep Learning to improve the performance of
features into clusters. Clustering is A subset of machine learning using machine learning models. Effective
used for data exploration, pattern neural networks with many layers to feature engineering can significantly
recognition, and identifying natural model complex data patterns. Deep enhance model accuracy and reduce
groupings within datasets. learning is particularly effective in overfitting.
handling large datasets with high-di-
mensional data, such as images, Feature Extraction
Convolutional Neural audio, and text.
Network (CNN) The process of transforming raw data
A deep learning model particularly into a format suitable for machine
effective for image and video recog- Dimensionality Reduction learning by identifying pertinent
nition tasks. CNNs use convolutional The process of reducing the number characteristics. This step reduces
layers to automatically learn spatial of random variables under consid- dimensionality and helps in focusing
hierarchies of features from input eration by obtaining a set of princi- on the most informative attributes for
images, making them well-suited for pal variables. This technique helps model building.
computer vision applications. improve model efficiency, reduce
computational costs, and avoid Generative Adversarial
overfitting in machine learning tasks. Network (GAN)
Cross-Validation
A technique for evaluating machine A class of machine learning frame-
learning models by partitioning data Dropout works where two neural networks
into training and validation sets. It A regularization technique for neural compete to generate realistic data
helps assess model performance networks that randomly ignores samples. GANs are often used to
and generalizability by reducing certain neurons during training to create high-quality synthetic images,
overfitting and ensuring that the prevent overfitting. By “dropping out” videos, and even text.
model works well on unseen data. nodes, dropout reduces reliance on
specific neurons, improving model
generalization on unseen data.
Data Augmentation
A technique that artificially expands
training data by generating variations
of existing data samples. Common
methods include rotation, scaling,
flipping, or adding noise to images,
which helps improve model robust-
ness and prevent overfitting.
14 www.elektormagazine.com
Parameter Optimization
The process of finding the best
model parameters to minimize the Unsupervised Learning
error during training. This involves Support Vector Machine A type of machine learning where
adjusting parameters like weights (SVM) models learn patterns from unlabeled
and biases to improve the model’s A supervised learning algorithm data without specific guidance.
accuracy and performance. used for classification and regression Unsupervised learning is used for
tasks, finding the optimal decision tasks like clustering, dimensionality
boundary. SVM aims to maximize the reduction, and anomaly detection.
Perceptron margin between different classes,
The simplest type of artificial neural
ensuring robust classification. Variational Autoencoder
network, consisting of a single layer
used for binary classification tasks. (VAE)
The perceptron model serves as Tensor A type of neural network used for
the building block for more complex A multidimensional array used to generating new data samples similar
neural network architectures. represent data in neural networks, to a given dataset. VAEs learn the
especially in deep learning. Tensors distribution of the input data and
provide a framework for manipu- generate new, similar data points,
Recurrent Neural Network lating large datasets across multi- useful in image synthesis and
(RNN) ple dimensions, facilitating efficient anomaly detection.
A type of neural network that retains
computations.
information through feedback loops,
suitable for sequential data. RNNs Weights
are widely used for tasks such as Transfer Learning Parameters in neural networks
language modeling, speech recogni- A technique where a pre-trained that are adjusted during training to
tion, and time series prediction. model is fine-tuned on a new, similar minimize the loss function. Weights
task to leverage existing knowl- determine the strength of connec-
edge. Transfer learning is especially tions between neurons, influencing
Regularization useful when training data is scarce or how input signals are transformed
Techniques to prevent overfitting by into output predictions.
computational resources are limited.
adding a penalty to model complex-
ity during training. Regularization
methods like L1 or L2 norms reduce Underfitting
overfitting and improve model gener- A modeling error where a machine 240535-01
Supervised Learning
A type of machine learning where
models learn from labeled datasets
to make predictions or decisions. The
model is trained using input-output
pairs to map inputs to the correct
outputs, suitable for tasks like classi-
fication and regression.
Raspberry Pi
AI Camera
Taking the Hassle Out of the Edge
Figure 1: The Raspberry Pi AI Camera (note that the Raspberry Pi is not included).
16 www.elektormagazine.com
tasks, including firmware management, communication, and
ensuring smooth operation between the camera module and the
Raspberry Pi.
The RP2040, the same chip used in the Raspberry Pi Pico, is respon-
sible for coordinating communication between the IMX500 and
the Raspberry Pi. While it doesn’t perform the AI inference, it plays
a key role in ensuring that the neural network models and camera
functions are loaded and operate correctly. Once the RP2040 sets
everything up, the IMX500 handles the AI processing.
By leveraging both the IMX500 for neural network tasks and the
RP2040 for control and management, the Raspberry Pi AI Camera
efficiently handles AI inference tasks, such as object detection and
pose estimation, all without heavily taxing the Raspberry Pi’s CPU.
Sony’s IMX500 is the world’s first intelligent vision sensor with edge
processing functionality, meaning it doesn’t require a round trip
to a server or external accelerator for AI tasks. Instead, all the AI
inference is done right on the sensor itself. This design eliminates
the need for external processors or high-performance chips, signifi-
cantly reducing the load on the Raspberry Pi’s CPU and allowing
for real-time AI-driven applications.
18 www.elektormagazine.com
Figure 4: Some raspberries on a pie, or a “doughnut” according to the Figure 5: Ashton has the ability to transform between different mammal
trained model. species.
the still-in-beta Raspberry Pi Connect service [2], since SSH alone Speaking of children, since I wanted some action, I enlisted the help
wasn’t enough for this job. There were a few glitches, but again, of Chase and Ashton, two tykes who have more energy than I do.
it’s still in beta.
Then I tried some moving targets. Getting Ashton to play with a
With the camera working, and Raspberry Pi Connect running on football yielded a human (Figure 5, left), but it wouldn’t detect the
my Windows 11 laptop, I was able to go mobile and try the camera football, at least under those lighting conditions. I asked him to
out “in the wild.” Since AI cameras will likely be used in various crouch down and pick up the ball, but this instantly transformed
environments, I wanted to test mine outdoors in less controlled him into a “dog” (Figure 5, right).
lighting conditions.
Pose Estimation
Object Detection For pose estimation, the camera uses PoseNet, a neural network that
Using the aforementioned rpicam-hello command line, I tried labels key points on the body, identifying joints and limbs. Unlike
object detection. This identifies objects by providing bounding object detection, pose estimation requires additional post-process-
boxes and confidence values for each object detected. The process- ing on the Raspberry Pi to generate the final output. Once it was
ing happens directly on the camera, with no significant post-pro- running, we were able to overlay stick figures, both in good light-
cessing needed on the Raspberry Pi itself. Once the output tensor ing (Figure 6, left), and when it got a bit darker (Figure 6, center),
is generated, the system can draw bounding boxes and labels on but with high-speed tests, such as Chase sprinting past the lens,
the image. the camera sometimes lost track of the figures, even at one point
chasing Chase (Figure 6, right). It also struggled a bit with motion
I tried a variety of everyday objects, even attempting it to get it blur, so good lighting would be preferable for reliable results.
to recognize some raspberries. It told me I was likely looking at a
“teddy bear.” Then I tried a pie, and got nothing. So I put the raspber- Besides taking control of the lighting, you could also tweak the
ries on the pie (Figure 4), and lo and behold, I had a “doughnut.” brightness, exposure, and ISO settings from the same command
All fun and games, but the pie was enjoyed, and the children have line to maintain decent image quality. Your end application may
discovered that they now like raspberries. have to automate this if you can’t control the ambient lighting.
Figure 7: The Raspberry Pi Camera Module 3 and prior models fit into this
multi-camera test jig.
WEB LINKS
[1] Raspberry Pi Documentation: AI Camera: https://raspberrypi.com/documentation/accessories/ai-camera.html
[2] Raspberry Pi Connect remote control: https://www.raspberrypi.com/software/connect
20 www.elektormagazine.com
PROTEUS DESIGN
Driving SUITE
forward with Manual Routing
[email protected]
EDITOR’S PICKS
Artificial Intelligence
in Elektor
By The Elektor Content Team
Once science fiction, artificial intelligence (AI) is now a cornerstone of
Join us on a fascinating journey through modern technology. Elektor, a pioneer in electronics with articles dating
Elektor’s archives, showcasing how back to 1961, has been at the forefront of this evolution, exploring AI’s
potential since its nascent stages. Whether you manually flip through
artificial intelligence (AI) has evolved old editions of ElektorMag or use the beta version of our Elektor GPT [1],
within the electronics community. you will see that AI-related topics have been covered for decades.
From early experiments in machine From discussions of neural networks and fuzzy logic in the 1970s and
1980s to in-depth projects featuring today’s sophisticated AI-driven
learning to the integration of AI in solutions, our coverage has mirrored the swift advancement of AI
modern projects, discover how AI has tech. Here, our editors and engineers offer a selection of significant
influenced technology trends, inspired AI-related articles from our vast archives. Of course, not every article
is ostensibly about AI. But the concepts and ideas explored, such as
innovation, and shaped the future of pattern recognition, automation, and machine learning, have been
electronics design. Check out these integral to the development of AI tech.
editor’s picks.
Focus: Discusses cybernetic models simulating animal behavior, exploring concepts of learn-
ing, adaptability, and intelligence in artificial systems.
The ‘cybernetic beetle’ is the first of a series ship between the stimulus and the relevant
of articles in ‘Elektor’ on designs which are reaction, the more the behaviour of the model
on the one hand meant to be a game, but approaches that of the animal example and
which on the other hand should be regarded the more will an ingenious toy become a
as serious and sometimes scientific imita- scientific object. It was found to be extremely
tions of animal behaviour. These cybernet- difficult to imitate the behaviour of more highly
ics projects have an electronic ‘nerve system’ developed animals in a cybernetic model,
enabling them to react specifically to exter- because an electronic nerve system can only
nal acoustic, optical and tactile stimuli. Such perform a limited number of functions. Exper-
models can moreover be designed so that iments on a scientific basis therefore confine
the reaction is not only governed by the type themselves to certain aspects of behaviour
of stimulus, but also by the condition of the or to living models of a very simple nature.
model at the moment when the stimulus Continue reading: www.elektormagazine.com/
is applied. The more ‘natural’ the relation- magazine/elektor-197506/57395
22 www.elektormagazine.com
Computers and Chess: How the Monster Thinks (Elektor, January 1979)
Focus: Discusses the development of chess-playing computers and highlights key contribu-
tions in AI, particularly by Claude Shannon.
Decades ago, with the electronic computer still in its infancy and illustrating above all else the
First Law of Thermodynamics (‘Work is Heat’), the game of chess attracted the interest of a
number of researchers in the field of artificial intelligence. The first person to actually propose
how a computer might be programmed to play chess was the English Mathematician Claude
Shannon. In 1949 he presented a paper entitled ‘Programming a computer for playing chess’,
which was significant, both for the fact that it was the first paper expressly on this subject, and
more importantly since many of Shannon’s ideas are still employed in the strongest chess-play-
ing programs of today. Shannon’s interest in chess programming stemmed from his belief that
the game represented an ideal test of machine intelligence. Chess is clearly defined in terms
of legal operations (moves of the pieces) and ultimate goal (checkmate), whilst being neither
so simple as to be trivial nor too complex to be unsusceptible to analysis. Continue reading:
www.elektormagazine.com/magazine/elektor-197901/58282
Focus: Discusses the evolution of artificial intelligence, from Focus: Discusses some of the problems in ascribing intelligence
its Charles Babbage and Alan Turing to its development as a to computers, and investigates intentionality, the origin of self
recognized field in 1956, while addressing the misconceptions awareness, and brain and machine translations
and myths surrounding machine intelligence
In his article “Artificial Intelligence,” M. Seymour provides an
Man is intelligent, but his intelligence is often thwarted (or interesting and informative account of some of the problems
worse) by his environment. That realization has given rise to met by computer designers in attempting to produce machines
a dream: that one day it may be possible to build a machine that exhibit artificial intelligence. The article discusses
that can think, that is, need not be programmed to perform its arguments for and against what constitutes artificial intel-
functions. Machine intelligence was first thought of by Charles ligence, including the existence or otherwise of intentional-
Babbage (1792-1871). Later, Alan Mathison Turing (1912-1954) ity (Searle, 1984). The present paper examines some of the
achieved immortality through the Turing Machine, which concepts from the point of view of a psychologist, who was a
purports to show that machines are mathematical objects, student at Manchester when Alan Turing was working on the
and his proof of the theorem that the set of mathematical theoretical aspects of information processing. The power of
tasks that is computable is exactly the same as the set that electronic devices has increased enormously since that time,
can be executed by the machine. He also formulated a theory but perhaps there has not been a similar growth in defin-
about what questions could in principle be answered by an ing the terminology used to describe computer activities and
intelligent machine. Artificial intelligence grew out of the work brain activities. At the simplest level there has been revival of
on digital computers during the Second World War and was anthropomorphism, a condemnatory appellation feared by
officially recognized as a branch of computing science in 1956. biologists accused of reading human characteristics into the
Since those early days, artificial intelligence has given rise to a behaviour pattern of lower animals. However, equally imprecise
number of myths, particularly, but not only, in the popular press. use of language is exemplified by phrases such as ‘comput-
However, claims of computers achieving this and that, without ers talking to each other’. This is largely a matter of economy
human intervention, always prove, on close examination, to be in the use of words, since it is easier to use concepts already
mere illusions of intelligence. These illusions are created by the in existence than to invent new ones, but there are dangers
fact that computers work so extremely fast. Continue reading: in over-extending the concepts to include things that are not
www.elektormagazine.com/magazine/elektor-198805/47340 justifiable. Continue reading: www.elektormagazine.com/
magazine/elektor-198911/47684
Focus: Discusses neurons, the possibilities of implementing the neurocomputer, modeling an artificial neural network (ANN), and training
Neurons are usually organised into well-de- each connection. The number of possi- was made until the advent of VLSI. Now,
fined structures, such as the brain, the ble connections is far greater than the with the enormous computing power of
spinal cord and the peripheral nerves. Each number of neurons present. We estimate even the smallest of bench-top comput-
neuron is a centre of information transfer that a human brain may contain as many as ers, we model ANNs mathematically. This
(Note: transfer, not storage). It can receive 1016 connections, an enormous resource for can be done in a system based on conven-
information as electrical signals from a memory and intelligent action... Given that tional microprocessors, as illustrated by the
number of other neurons in the network, the neural network of an animal is capable software described later. There are also
process this information, and pass it on of complex recognition and control actions, custom-designed processors used to build
to other neurons. In the human brain, for researchers have tried to build the artifi- true neurocomputers. These are designed
instance, a neuron connects to as many as cial equivalent, an artificial neural network to excel in the particular kinds of process-
10,000 other neurons. The extent to which or ANN. An ANN consists of neuron units ing that are needed to model ANNs, which
information is transferred from neuron to mimicking the action of animal neurons. is done most efficiently by using parallel
neuron depends on the number of physi- They have input, processing and output processing. Continue reading:
cal connections existing between the stages. The earliest electronic ANNs were www.elektormagazine.com/magazine/
neurons and the intensity (or strength) of based on valve circuitry, but little progress elektor-200110/17112
24 www.elektormagazine.com
Practical Neural Networks (Elektor, January 2003)
Focus: Covers neural networks, the birth and history of the ANN, and learning and training algorithms
Artificial Neural Networks (Neural Nets or just experiment with your own Neural Nets. A Neural
ANNs for short) are a popular form of Artificial Net is a network of connected processors. Each
Intelligence (AI). They are based on the operation individual processor is only capable of a very
of Brain Cells and many researchers think that simple mathematical task, but when many are
they are our best hope for achieving true intelli- connected together complex behaviour results.
gence in a machine. If you’re a fan of the TV series The drawing in Figure 1 shows a typical neural
“Star Trek,” you’ll know that Data is supposed to net. To understand the Neural Network let’s look
have a Neural Net brain, as is the robot in the at its inspiration - the brain. What a layman calls
“Terminator” films. Although these technologi- ‘Brain Cells’ are what a biologist would refer to
cal wonders are on the cutting edge of research as Neurons. These are the tiny living cells, which
in Computer Science, they are also well within make up our brain and nervous system. There
the grasp of the enthusiastic amateur. The aim are about 100 billion of them in a typical human.
of these articles is to introduce this fascinating Continue reading: www.elektormagazine.com/
topic in a practical way, which will allow you to magazine/elektor-200301/17413
Focus: Covers the Nvidia Jetson Nano, training with the Jetson Nano,
development via a web browser, and more
Hailo AI Kit
with Raspberry Pi 5
By Dogan Ibrahim (United Kingdom)
Features
Editor’s Note. This article is an excerpt from the Elektor book Getting > Contains a neural network inference accelerator capable of
Started with the Raspberry Pi AI Kit, which will be published by Elektor 13 TOPS
in 2024. It was formatted and lightly edited to match ElektorMag’s > Fully integrated into Raspberry Pi’s camera software stack
conventions and page layout. The author and editor are happy to help > Thermal pad pre-fitted between module and HAT+ spreads
with queries. Contact details are in the Questions or Comments? box. heat across components, improving performance
> Conforms to Raspberry Pi HAT+ specification
26 www.elektormagazine.com
> 16 mm GPIO stacking header To achieve optimal performance from the Hailo device, it is neces-
> 4 threaded spacers sary to set PCIe to Gen3. While using Gen2 is an option, it will result
> 8 screws in lower performance. The steps are:
> 1 knurled double-flanged drive attachment screw to secure
and support the M.2 peripheral pi@raspberrypi:~ $ sudo raspi-config
Hardware Installation Select option 6. Advanced Options, then select option A8 PCIe Speed.
Figure 2 shows the AI Kit with the Raspberry Pi 5. The AI kit must Choose Yes to enable PCIe Gen 3 mode. Click Finish to exit.
be installed on top of the Raspberry Pi 5 before it can be used. It is
recommended to use the AI Kit with the Raspberry Pi active Cooler. Reboot your Raspberry Pi 5:
Thus, if you have an Active Cooler, make sure that you install it
before installing the AI Kit. Also, it is recommended to install the pi@raspberrypi:~ $ sudo reboot
Raspberry Pi 5 camera (e.g., camera V3) before you install the AI Kit,
as this way it will be easier to connect the camera cable. Installing the Hailo AI Kit Software
Run the following command to install the Hailo AI Kit software
Installing the AI Kit Software on Raspberry Pi 5:
First of all, you should ensure that your Raspberry Pi 5 is installed
with the latest Bookworm operating system. pi@raspberrypi:~ $ sudo apt install hailo-all
Run the following commands to update the operating system to The above command installs the following dependencies:
latest version:
> Hailo kernel device driver and firmware
pi@raspberrypi:~ $ sudo apt update > HailoRT runtime software
pi@raspberrypi:~ $ sudo apt full-upgrade > Hailo Tappas core package
> The rpicam-apps Hailo post-processing software demo stages
Ensure that the Raspberry Pi 5 firmware is up to date:
Reboot your Raspberry Pi 5 for the above settings to take effect:
pi@raspberrypi:~ $ sudo rpi-eeprom-update
pi@raspberrypi:~ $ sudo reboot
If you see December 2023 or a later date, proceed to the next step.
If you see a date earlier than 6 December 2023, run the following Verifying the Software Installation
command to open the Raspberry Pi configuration tool: You should verify the software installation to make sure that all
the software components are in place and the AI kit can be recog-
pi@raspberrypi:~ $ sudo raspi-config nized by the Raspberry Pi 5. The steps are:
Under Advanced Options Bootloader Version, choose Latest. Then > Make sure the AI kit hardware is installed on your
exit raspi-config with Finish or the Escape key. Run the following Raspberry Pi 5 as described earlier
command: > Enter the following command:
cd hailo-rpi5-examples
Figure 5: Checking kernel logs (part of the display is shown).
> To run the examples, you should ensure your environment is
set up correctly. You can set it all up by sourcing the following
> You should also test for the TAPPAS Core installation by script. This script will set the required environment variables
running the following command: and activate Hailo virtual environment (if it doesn’t exist, it
will create it).
pi@raspberrypi:~ $ gst-inspect-1.0 hailotools
source setup_env.sh
If everything is ok, you should see something similar to Figure 4.
> Make sure you are in the virtual environment and run the
If hailo or hailotools are not found, try deleting the GStreamer following command. This may take some time, wait until it is
registry: finished.
If you are using a V3 camera module with your Raspberry Pi 5, add The applications programs (detection, pose estimation, instance
the following lines to your config.txt file: segmentation) are in folder basic_pipelines as shown in Figure 7.
28 www.elektormagazine.com
or, enter the command:
v4l2-ctl –list-devices
You can test whether the USB camera is working by entering (Note
that it is lowercase L, not 1):
Figure 6: Examples folder contents.
ffplay –f v4l2 /dev/video0
Figure 7: Applications programs. For example, to read images from the USB camera, the author used
the option –i /dev/video8. In the following example, a keyboard
is detected using a USB camera:
cd hailo-rpi5-examples
source setup_env.sh
python basic_pipelines/detection.py --input resources/
detection0.mp4
To close the application press Ctrl+C. For additional input options, Figure 8: Output of the program.
enter the following command:
10k
GPIO5 29 30 GND
an LED is turned ON when a person is detected. The program waits GND 39 40 GPIO21
R2
with the LED ON until the user presses a reset button to acknowl-
330Ω
edge the detection. At this time, the LED turns OFF and the detec-
tion process starts again. This is a simple but useful example. The LED1
LED can be replaced with a relay or a buzzer if required. Also, the
program can be modified to detect objects other than persons.
Circuit diagram: The circuit diagram is shown in Figure 11. Figure 11: Circuit diagram.
The LED is connected to port pin 21 of Raspberry Pi 5 through a
330-Ω current limiting resistor. The pushbutton is connected to
port pin 20. The default state of the button is at logic 1 and goes to Object Detection Training
logic 0 when the button is pressed. AI-based object detection and training is a highly complex process
and requires good understanding and working knowledge of
Program listing: The Python program listing is shown in programming concepts, especially Python programming. Chapter
Listing 1. The program creates a subprogram and runs as a shell 11 of the book describes in detail how to carry out object detection
program. At the beginning of the program, the gpiozero library is training using an Ubuntu-based computer, where the output is
imported and Raspberry Pi 5 GPIO port 21 is assigned to led and loaded to a Raspberry Pi 5.
button is assigned to port 20. 240562-01
30 www.elektormagazine.com
Listing 1: Python program.
#-----------------------------------------------------------------
# DETECT PERSON AND TURN ON LED
# ---------------------------------------------------
#
# File : Detect.py
# Date : October, 2024
# Author: Dogan Ibrahim
#----------------------------------------------------------------
import os
import subprocess
from gpiozero import LED, Button
from time import sleep
led = LED(21) # LED port
button = Button(20) # Button port
led.off() # LED OFF
while(True):
p=subprocess.call("rpicam-hello -n -v 2 -t 0 \
--post-process-file /home/pi/rpicam-apps/assets/hailo_yolov8_inference.json\
--lores-width 640 --lores-height 640 2>&1 | grep -m 1 -c \
--line-buffered 'person'",shell=True)
print("Person detected...")
#
# At this point a person has been detected
#
led.on()
button.wait_for_press() # Wait for button press
led.off()
sleep(15)
Questions or Comments?
Do you have any questions or comments related to this article?
Email the author at [email protected] or Elektor at
[email protected].
Related Products
> Dogan Ibrahim, Getting Started with the Raspberry Pi
AI Kit (Elektor 2024)
www.elektor.com/21031
~40%
reduce energy costs and emissions, emphasizing the need for
further studies to quantify AI’s full potential. The study proposes
a systematic approach to evaluate AI’s impact, predicting
~90%
significant reductions in energy use and emissions by 2050.
compared to the
With AI technology and efficiency policies, CO2 emissions could BAU scenario.
be cut by around 40% by 2050 compared to maintaining the
current trajectory without any intervention (BAU). Implementing from the BAU scenario when
both AI and policy-driven efforts could lead to a 60% reduction. combined with energy efficiency
By further incorporating low-emission power generation, policies and low-emission power
emissions could be nearly eliminated by 2050, achieving savings generation (LEPG).
of up to 93–95% compared to current trends.
200
150
on AI adoption and usage in the
top EU countries (by population).
Scenario
100 Frozen
BAU wo/AI Drafts
BAU w/AI
50 Policy wo/AI Here’s a summary of AI adoption
Policy w/AI and usage in the top EU countries
by population (as of 2024) Germany:
0
2020 2030 2040 2050 Around 11% of companies are using AI
technologies, focusing on automation,
14
manufacturing, and automotive
sectors (European Commission).
12 France: AI adoption is about 10%, with
10 key applications in healthcare and
CO2 emissions (MT)
32 www.elektormagazine.com
Tech Giants Developing AI Chips
Due to the global chip shortage caused by the > Google: Improving its Tensor Process- > Meta: Developing a custom chip for its AI
COVID-19 pandemic in 2020, the production of ing Unit (TPU) [4] technology for Google initiatives [9].
GPUs was severely impacted. The pandemic Cloud. > Huawei: Prioritizing AI chip production,
disrupted the global supply chain, resulting in > OpenAI: Exploring the development of slowing down smartphone production
delays in chip production and delivery. As a proprietary AI chips [5]. [10].
result, several companies have started creat- > Microsoft: Launched two custom chips — > Tesla: Created the Dojo AI chip [11] for
ing their own AI chips. Here’s a list of those Microsoft Azure Maia AI Accelerator and machine learning in autonomous driving.
companies: Azure Cobalt CPU [6]. > Baidu: Developed the Kunlun AI chip for
> Amazon: Released the Inferentia AI chip deep learning and speech recognition.
[7] and second-gen AWS Trainium ML > Alibaba: Released the Hanguang 800
accelerator [8]. AI chip [12] to enhance ML in cloud
services.
240435-01
76%
of respondents either use
vs 70% from last year.
62%
now actively use AI tools
vs 44%
in the previous year.
or plan to use AI coding
assistants
WEB LINKS
[1] N. Flaherty, “AI can cut smart building energy management by over 19%,” eeNews, 2024: https://tinyurl.com/ai-smart-energy
[2] C. Ding, J. Ke, M. Levine et al., “Potential of artificial intelligence in reducing energy and carbon emissions of commercial buildings
at scale,” Nat Commun (2024): https://doi.org/10.1038/s41467-024-50088-4
[3] “2024 Developer Survey,” Stack Overflow, May 2024: https://survey.stackoverflow.co/2024/ai/
[4] Accelerate AI development with Google Cloud TPUs: https://cloud.google.com/tpu?hl=en
[5] A. Tong, M. Cherney, C. Bing, S. Nellis, “Exclusive: ChatGPT-owner OpenAI is exploring making its own AI chips,” Reuters, 2023:
https://tinyurl.com/chatgpt-chip
[6] J. Siegel, “With a systems approach to chips, Microsoft aims to tailor everything ‘from silicon to service’ to meet AI demand,”
Microsoft, 2023: https://tinyurl.com/microsoft-ai-chip
[7] AWS Inferentia: https://aws.amazon.com/machine-learning/inferentia/
[8] AWS Trainium: https://aws.amazon.com/machine-learning/trainium/
[9] F. Potkin, J. Zhu, “aExclusive: AI chip demand forces Huawei to slow smartphone production,” Reuters, 2024:
https://tinyurl.com/huawei-chip
[10] K. Paul, S. Nellis, M. Cherney, “Exclusive: Meta to deploy in-house custom chips this year to power AI drive,” Reuters, 2024: https://
tinyurl.com/meta-chip
[11] “TSMC Reportedly Commences Production of Tesla’s Next-Generation Dojo Chips, Anticipates 40x Increase in Computing Power
in 3 Years,” TrendForce, 2024: https://tinyurl.com/tesla-chip
[12] Y. Jiao, L. Han, X. Long, et al.,“Hanguang 800 NPU,” Alibaba Group: https://tinyurl.com/alibaba-chip
AI-Based Universal
IR Remote Control
Gesture-Controlled with MediaPipe and Raspberry Pi
34 www.elektormagazine.com
Interaction with machines is then an area we deal with daily, and
has become crucial in a wide range of industries, helping to improve
efficiency, safety and the overall user experience. Today, many of the Figure 2: Recognized points on palm — landmarks.
HMI systems take advantage of artificial intelligence (AI) for their (Source: Google https://tinyurl.com/34thk8xf)
operation.
The project we propose in this article uses hand gesture recognition to MediaPipe is defined by Google as on-device, meaning it is also capable
give commands to a television set. We will use an AI system to replace of running on an offline hardware device, without the need for an
one of the most common and “comforting” devices in everyday life, internet connection. This makes our projects portable and integrable
the remote control. At the end of the project, you’ll have a lot of fun in various contexts. Google adds the term no-code to its platform,
turning on the TV set with the “Jedi force” of palm opening! meaning it provides a system that requires little programming knowl-
edge to achieve its goal.
The approach of the project is playful, but it is intended to be a gateway
to the use of AI systems by everyone, in this case aimed at creating A concept we are familiar with from the Arduino universe, which
gestural HMI. disclosed the world of electronics and code writing even to those
who did not have the basics. MediaPipe also aims in this direction,
Software proposing in a simple way an originally very complex topic like AI.
AI is a field of computer science that focuses on developing systems
and technologies that can simulate human intelligence processes, Let’s see its potential at MediaPipe Studio gesture recognition webpage
i.e., think and solve problems that we humans are used to. Machine [2]. We need to log in with a Google account, allowing the browser
learning (ML), on the other hand, is a fundamental subset of AI that to use the webcam. We frame our hand, it doesn’t matter whether left
studies how to make a computer system learn from past data to make or right, as it also identifies which one it is, and perform one of the
predictions or decisions, without being explicitly programmed to do so. following gestures:
The first step in ML is the acquisition of data, which can be of various 1 - Fist
types, such as text, images, sounds, or numbers. They can come from 2 - Open palm
sensors, databases, or even social media. The importance of quality data 3 - Index finger pointing up
is critical in determining the success of an ML model. ML algorithms, 4 - Thumb pointing up
on the other hand, are the tools that enable computer systems to 5 - Thumb down
learn from data. There are various types of algorithms, each of which 6 - Victory symbol with two fingers
is suited to specific tasks. For example, regression algorithms can be 7 - I love you in the language of gestures (final position).
used to make predictions based on historical data, while classification
algorithms are useful for assigning categories to data. The page will show, in real time and overlaid on the video, 21
key palm points connected by colored segments, as visible in Figure 1.
Next comes the process of training an ML system (algorithm + data), The key points are also referred to as landmarks and represent the
which involves feeding the algorithm with labeled data; that is, data significant parts of the hands, such as fingertips, thumbs, palms, and
that already has correct answers associated with it. The algorithm then so on. Precise tracking of these landmarks provides insight into the
uses this data to learn the relationships. This step requires a certain pose and movements of hands within an application (Figure 2).
amount of time and computational resources, but it is critical to the
creation of accurate models. On the web page, below the video frame, there will also be a range of
additional information, such as the percentage of confidence in having
Once trained, the model must be evaluated to determine how well recognized the gesture performed and, of course, the type of gesture.
it performs on data that are not present in it. This step is crucial to MediaPipe then offers a solution called Hand Tracking that enables
understand whether the model can generalize well beyond the data real-time hand recognition and tracking within a video stream. This
with which it was trained. If the model does not meet the expected module of MediaPipe has been named HandLandmarks accordingly.
performance, it may need to be optimized by adjusting various param- The module begins by detecting the presence of hands in the video
eters or using tuning techniques. This process is known as model frame and identifies the regions of the image that contain them. Once
optimization and may require some experimentation to find the optimal detected, it begins tracking hand landmarks.
combination of parameters.
With the landmarks identified, the module can estimate the pose of
MediaPipe the hands within the video frame. This includes information such as
This big job of algorithm creation, training and optimization is provided hand orientation, finger direction, and other details that can be used
as Open Source by Google with the mighty MediaPipe platform. to interpret gestures. MediaPipe is based on TensorFlow lite, i.e., the
The meaning of the term MediaPipe is related to the concept of large ML platform (also from Google), but differs from it in that it is
media pipeline. already pre-trained. For example, gesture recognition takes advantage
240433-002
Figure 3: Schematic of the simple, plug-in IR Rx-Tx interface. Figure 4: The small IR interface board, mounted on Raspberry Pi 5.
of about 30,000 images taken from the real world. You can also train You must now download the data model for MediaPipe gesture recog-
the system yourself, with images of other gestures, by following the nition at the link [5]. Place it in the same folder where you will create
tutorial at [3]. the Python program.
Have fun exploring the other ML systems provided by MediaPipe such The second Python library we will use is OpenCV (Open Source
as image classification, object or face detection. The documentation Computer Vision Library), used for computer vision and image process-
therein will allow you to delve into the topics of most interest. MediaPipe ing. OpenCV provides a wide range of features for image analysis and
is also multi-platform; in fact, you can create projects for Android, iOS manipulation, pattern recognition (recurring patterns or regularities
and Web (JavaScript). In our project we will use Python, i.e. one of the within a data set), object tracking, computer vision, and much more.
most popular programming languages in the ML field (and beyond)
for several reasons: its ease of use, the intuitive syntax — and the Let’s install with pip install opencv-python. We have every-
wide range of educational resources and libraries available — make thing to try out on our stand-alone system (application or system
it an excellent choice for beginners and programming experts alike. that can run independently). If you are already a Python developer,
use the editor you are used to — we used Geany — already installed
One article would not even suffice as a primer for learning the big world on Raspberry OS. In Listing 1, you will find the program you need
of TensorFlow, MediaPipe and Python. But we would like you to use it to write on the editor commented and explained in detail. Run it
to understand its capabilities and to enable you to direct your study (airplane icon in Geany). A new window will then open with the live
of indispensable topics in present and future computing. video stream and hand landmark. The recognized gesture will appear
in the editor terminal.
MediaPipe on Raspberry Pi
Let’s start practically, by installing MediaPipe on our Raspberry Pi 5 Note how in the match...case section we have left as a comment (in
so that we can use it on-device right away. Connect to your board as Python, with the # symbol at the beginning of the line) the os.system
best you are used to, although we recommend VNC, for simplicity and instructions, i.e., those operating system commands that will allow
power of use [4]. Python is native in the Raspberry Pi operating system. sending the IR signals, which we will make operational after dealing
Take administrator rights with the sudo bash command and make with the hardware aspect.
sure you have everything updated with apt update and apt upgrade.
Acquiring and Sending IR Signals
Install the MediaPipe library for Python with the terminal command For learning and sending the infrared (IR) signals, we will make a
pip install mediapipe. In Python, pip is a package management simple interface — whose schematic is shown in Figure 3 — with a
tool that makes it easy to install, manage, and update external librar- tiny PCB housing, an IR receiver and an IR transmitter LED. With a
ies and frameworks. convenient plug, it will directly plug into the Raspberry Pi GPIO header,
as illustrated in Figure 4.
The name pip is a recursive acronym that stands for Python Installs
Packages. Some versions of the Raspberry Pi operating system may For image capture, we’ll use a USB webcam connected to Raspberry Pi.
give a package installation error; if so, clear the external package The design is perfectly compatible with whatever cam you have for
management with the following command rm /usr/lib/python3.*/ your board. To give support stability to the PCB, we used the first
EXTERNALLY-MANAGED, and re-run pip. 16 pins (numbering from 1 → 3.3 V to 16 → GPIO 23), see Figure 5.
36 www.elektormagazine.com
Figure 5: Raspberry Pi 5 GPIO’s pinout. (Source: https://tinyurl.com/5dpvj5ne)
38 www.elektormagazine.com
# Creating the gesture recognizer
recognizer = GestureRecognizer.create_from_options(options)
timestamp = 0
mp_drawing = mp.solutions.drawing_utils
mp_hands = mp.solutions.hands
# Initialization of the hand recognizer
hands = mp_hands.Hands(
static_image_mode=False,
max_num_hands=numero_mani,
min_detection_confidence=0.65,
min_tracking_confidence=0.65)
# Initializing webcam video capture
# If you have multiple video input devices connected to Raspberry
# you need to type the correct number in place of 0
cap = cv2.VideoCapture(0)
# Main program cycle
while True:
# Capturing a frame by the webcam
ret, frame = cap.read()
if not ret:
break
The v4l-utils utilities provide a set of tools to config- Figure 8: Recording and sending the other IR signals from the remote control.
ure, control, and manage these devices. In Listing 1, (Source: RealVNC www.realvnc.com/en/)
you noticed that the ir-ctl instruction is associated
with the os.system command (i.e., a Python instruction that directly transmission, and it is also easy to identify because it’s quite a large
executes a feature belonging to the system). number, compared to the others.
It is one of the utilities within v4l-utils that allows you to control IR Save the file and return to the terminal (ctrl+x ; yes). Direct the trans-
devices. With ir-ctl, you can send and receive infrared signals. In mitter to the TV and write from the terminal:
the /dev/ directory are lirc0 file for sending signals and lirc1 file for
transmitting, which are features derived from the LIRC package, now ir-ctl -d /dev/lirc0 --send=on_off.txt
integrated into the OS kernel in the latest versions of Linux. To learn
more about, you may pop by here [6]. If everything worked, your TV will have turned on “by magic” (or off,
if it was already on). Perform the same procedure for the other keys,
Put it to the test now, by writing: as illustrated in Figure 8. You can, of course, change the matches as
you wish. Those for our project are shown in Table 1.
ir-ctl -d /dev/lirc1 --receive=on_off.txt
We recommend placing the Python file, MediaPipe template gesture_
The terminal will remain waiting for events. Take the remote control recognizer.task and txt files in the main home folder (in our project,
you want to “clone”, press the on_off button while directing it to the /home/admin).
IR receiver. Try to press it quickly, and only once, so as not to send
too many codes at the same time. Press ctrl+c to end the acquisition. Run the Python file, and place your hand in the webcam frame. Alter-
Analyze with nano the on_off.txt file created. nate the gesture commands with the fist — which has no matched
instructions — so that you can discriminate them properly. Figures 9a
The file should appear as in Figure 7. The received number sequence to 9d show the system at work, recognizing the finger pointing up (9a),
is in mode2 which is a specific type of encoding of the captured IR open palm (9b), thumb down (9c) and thumb up (9d).
signals. Each pair of numbers represents the pulse lengths (+, or
pulse) and the intervals between pulses (-, or space). Mode2 is also While you were controlling your device by opening your palm, didn’t
a feature of lirc, as already mentioned now integrated into the OS. To you feel like a Jedi, at least for a while?
know more, you may visit [7].
If you have pressed the on_off key for too long, you may have stored Table 1: Hand gesture correspondences with TV commands.
multiple lines of mode2 codes. You will then have to delete those that
repeat. In fact, the first line of the encoding is enough; the others are Hand Gesture TV Command txt File
practically repetitions of the received encoding (actually, you can see Palm Open On-Off on_off.txt
the similarity between the lines). Thumb Up Volume Up volume_su.txt
Thumb Down Volume Down volume_giu.txt
After deleting the unnecessary lines, go to the end of the first one
and delete the last value, which represents the timeout between Finger Pointing Up Channel Fwd canali_avanti.txt
signal sendings (between lines). This value is not needed in the Victory Sign Channel Rev canali_indietro.txt
40 www.elektormagazine.com
a b
c d
Figure 9: These four images show the main gestures recognized by the system. On the right of each one, you may read the recognition sequences, that vary
according to the outcome of the process. (Source: RealVNC www.realvnc.com/en/)
WEB LINKS
[1] European Safety Transport Council on EuroNCAP: https://tinyurl.com/3rs8z9cv
[2] MediaPipe Studio gesture recognition webpage: https://tinyurl.com/44jxnep8
[3] MediaPipe customization guide: https://tinyurl.com/y9bbpu5h
[4] RealVNC VNC viewer download page: https://tinyurl.com/3dvhjfru
[5] MediaPipe gesture recognition task download: https://tinyurl.com/4xsrfz8z
[6] LIRC webpage: https://lirc.org/
[7] Ubuntu webpage for ir-ctl tool usage: https://tinyurl.com/68xpjd22
[8] Elektor Labs webpage for this article: https://www.elektormagazine.com/labs/ai-based-universal-ir-remote-control
AI
for Product
Concept Design
A Tour of the World of AI-Based Art Generators
Figure 1: Rendering of a Hi-Fi amplifier
created with Midjourney by the author.
Over the past year, AI for image creation lightning speed. New online services and models appear every
has taken a huge leap, making this week. Image quality is improving by leaps and bounds. There now
seems to be a product for everything.
technology accessible to everyone. Does
this give electronics hobbyists and creators Convenience serves man — if you can’t come up with a prompt
a powerful new tool? A few sketches and a yourself or aren’t creative, there is a paid service that will help
you with sample prompts, styles and specific templates for every
well-formulated text prompt are all it takes challenge, such as logo design, color palettes, app designs and
to get a photorealistic representation of our fashion design. Everyone seems to be jumping on this train, and
ideas. But is it really that simple? And what commercial parties are integrating AI into their existing services.
In addition to these online services, more and better offline models
use is it, in practice? and tools are becoming available, such as Flux-1-Schnell and
Stable Diffusion mentioned above.
Since the advent of AI, I have always been truly interested in its Many photorealistic portraits created with these generators are
creative capabilities, and immediately wanted to try the new tools barely distinguishable from real photographs, even to practiced
made available on the Web, such as Midjourney, Stable Diffusion, eyes. Effects that were difficult to realize just a few weeks ago —
Freepik Sketch, and Dall-E 3.0. In this article, I would like to give you such as text in images — are now no longer a problem. Distorted
an opinion on them, although this list is not exhaustive and at the limbs became rare.
time of publication may be already out of date. In my experiments,
I tried to create a design concept for an audio amplifier that might AI offers a new source of inspiration. With simple textual input,
look beautiful. Using a combination of sketches, photos of exist- AI can generate different variations of a design, which can lead
ing devices and directed prompts, I tried to bring my vision to life to unexpected ideas. Tools such as Midjourney and Stable Diffu-
using Midjourney and other tools. Along the way, I’ll explain jargon sion XL allow users to create multiple mockups from a sketch or
terms such as prompt-engineering, inpainting, and style-transfer. prompt, which helps discover design options that might other-
wise be overlooked.
Moving at Lightning Speed
If I were to start from an initial observation, I would have to say Figure 1 shows a rendering of a Hi-Fi amplifier created with
that developments in Gen-AI image generation are moving at Midjourney. (Refer to text box Get Started with Midjourney.)
42 www.elektormagazine.com
Get Started with Midjourney
How to get started with Midjourney: a one-click roadmap! variations can be addictive, just like other online activities. Each
time you view a new variation, you get a dopamine kick, similar
> Go to Midjourney’s official website [1]. to what you experience when gaming or gambling.
> Click “Sign In” to log in with your Discord account or
Google account. Limitations, Mediocrity
> That’s all. Gen-AI such as Midjourney and Stable Diffusion work from a large
data set of existing images. AI combines elements from this data
to create a kind of “average” view. This can make it feel that truly
new images are difficult to create, since Gen-AI always falls back
Prompt Engineering on what it has “seen” before.
Prompt engineering is the targeted formulation of text commands
to guide Gen-AI, such as Midjourney and Stable Diffusion, in creat-
ing images. In the context of product design, this means using
precise words and descriptions to direct the AI to generate exactly
the desired shapes, styles and details. It’s all about precision in your
task, so that the Gen-AI creates images that match your vision.
This can be tricky, since the same prompt always yields different
variants, as shown in the four examples on Figure 2. This is because
AI uses a random number, called seed, which you can also fix with
Stable Diffusion.
Smart prompt engineering allows users to force unique and surpris- Cost and Accessibility
ing combinations. The power of AI lies precisely in combining Traditional product design can be time-consuming and expensive,
elements in unexpected ways, creating images that feel original especially for hobbyists working with limited resources. Gen-AI
and different, even when based on existing data. While AI cannot tools significantly lower this barrier by making it possible to gener-
create entirely new things from scratch, it can produce results that ate designs quickly and inexpensively. Instead of spending hours
are perceived as unique because of the way it reinterprets famil- sketching and modeling, designers can now create dozens of images
iar elements. within minutes.
Using Your Own Images The availability of affordable or free Gen-AI makes this technol-
Incorporating your own photos and images into the AI design ogy accessible to a wide audience. Tools like OpenAI’s DALL-E
process can significantly improve results. By uploading images of (via ChatGPT website) and Flux or Stable Diffusion (via poe.com)
existing designs or inspiring objects, the Gen-AI can generate more offer even free access to basic functions, allowing hobbyists to get
specific and relevant designs. In Midjourney, you can upload and started in no time.
merge multiple images via the /blend function and also combine
them with a prompt, as shown on Figure 4, which illustrates the For makers, it may not be worth learning all the ins and outs of
merge of two images into a final one. GenAI tools. These tools change quickly and become obsolete at the
same pace. In addition, creating graphics is often not up the alley
Use of Weighting Factors and Style References in of electronics engineers, who are more focused on function than
Prompts form. Look around you for people whose hobby is GenAI-prompt-
Weighting factors in prompts can be used to emphasize certain ing, just as you have your own hobby. Collaborating with them can
elements of the design. This provides more control over the result be not only enjoyable, but also mutually instructive.
and helps create designs that more accurately reflect the intended
vision. You can use :: and numeric values for this purpose. Overview of Online AI Art Generators
Bing Image Creator
One example in Midjourney: If you want the AI to emphasize a > AI art model: DALL-E 3.
device in the foreground and not in the background, you can do > Platform: Web.
this with a prompt such as: > Cost: Free of charge.
/imagine a high-tech speaker on a table in a modern Bing Image Creator is the result of the collaboration between Micro-
living room, clean design, minimalist ::2 background soft and OpenAI. It uses the latest DALL-E model, DALL-E 3, and
blurred ::0.5 is currently available for free.
Here minimalist has a weighting factor of 2 compared to the other DALL-E 3 (via ChatGPT)
elements and background blurred just a weighting factor of 0.5. > Platform: Web (via ChatGPT).
> Cost: $20/month as part of ChatGPT Plus.
Style references refer to another image to adopt a specific style. You
do this by using --sref followed by the URL of the reference image. DALL-E 3 is a substantial upgrade over DALL-E 2, especially if you
have a ChatGPT Plus subscription. The results are significantly
In Midjourney, if you want to adopt a specific style of an image, better, and you have more control by combining it with ChatGPT.
use, for example:
/imagine futuristic device with blue accents --sref Canva
https://example.com/image.jpg > AI art model: Stable Diffusion.
44 www.elektormagazine.com
> Platform: Web, iOS, Android. > Cost: Free for 25 credits per month; from $5/month for
> Cost: Free; from $12.99/month for Pro with more AI features. 100 credits per month (and included with various Adobe
subscriptions).
Canva recently added a text-to-image art generator. This feature
integrates seamlessly with the rest of the template-based design Although you can use it online, it is now integrated directly into
app, allowing you to add AI-generated art to everything from social Adobe products such as Express and Photoshop.
media posts to birthday cards.
One of Firefly’s best features is the ability to create custom text
NightCafe effects with a written prompt.
> AI art models: Stable Diffusion, DALL-E 2, CLIP-Guided Diffu-
sion, VQGAN-CLIP. Quora Poe
> Platform: Web. A platform, Quora Poe, an application or service created by Quora,
> Cost: From $6/month for 100 credits (good for about 1,240 is available on the Web. This platform allows users to interact with
images per month). various AI models, including ChatGPT and other AI-based chatbots.
On it you can find, among others, FLUX-schnell at [2] and Stable
NightCafe offers additional features such as styles for DALL-E 2 and Diffusion at [3]. There will probably be a limited number of credits,
Stable Diffusion, and allows you to use older generative art models. but you can try them out.
Like NightCafe, OpenArt offers additional features for Stable Diffu- What is noticeable, however, is that the image is constantly chang-
sion and DALL-E 2, plus access to additional open-source models. ing, making it difficult to control accurately. Sizing and techni-
You have more control over the specific details of the images you cal precision are lacking in all ImageGen-AI. Figure 5 shows an
generate. OpenArt also offers options such as sketch-to-image and example of rendering: the rendered image on the right is derived
a stock art transformer that adapts stock images to your needs. directly from the (very) rough sketch made by hand on the left.
Adobe FireflyFl FreePik is free for a limited number of actions per day, but if you
> Platform: Web, Adobe Express, Adobe Photoshop, and other really want to get started, a subscription is required. In addition
Adobe tools. to FreePik, there are numerous new online services now available.
Stable Diffusion web UI: if you would like to get started with this Author's Note
one on your own PC, you may take a look at [6]. Again, a powerful Those interested in learning more about AI may read the book,
video card is essential for a smooth operation. Living and Learning With AI, written (in Dutch) by my ICT faculty
colleagues [7].
Technical Limitations of Gen-AI in Design
Technical constraints on form and function make the engineer’s
job both interesting and indispensable. An engineer must consider
a wide range of requirements-from functional performance to
manufacturability, maintainability and recyclability, also known
Related Product
as Design for X (DFx). Gen-AI tools are currently not (yet) able to
provide for this process; while they can quickly generate pretty > D. Situnayake, Jenny Plunkett, AI at the Edge
pictures, the real value of good design lies in the practical appli- (O’Reilly, 2023)
cation of engineering knowledge and experience. www.elektor.com/20465
WEB LINKS
[1] Midjourney’s official website: https://www.midjourney.com/
[2] FLUX-schnell at Quora Poe website: https://poe.com/FLUX-schnell
[3] Stable Diffusion XL at Quora Poe website: https://poe.com/StableDiffusionXL
[4] Pikaso’s website: https://www.freepik.com/pikaso
[5] Website for Flux.1 testing: https://huggingface.co/black-forest-labs/FLUX.1-schnell
[6] Stable Diffusion on GitHub: https://github.com/AUTOMATIC1111/stable-diffusion-webui
[7] R. Huijts, K. Suilen, D. Bloks, E. Saçan ”Leven en Leren met AI” (Noordhoff Business): https://tinyurl.com/hdej6mpm
46 www.elektormagazine.com
Get your hands on
cutting-edge
AI Hardware!
Raspberry Pi AI Kit Unitree Go2 Pro
The Raspberry Pi AI Kit includes the Raspberry Quadruped Robot
Pi M.2 HAT+ and a Hailo AI acceleration module The Unitree Go2 is a quadruped robot
for use with the Raspberry Pi 5. It provides an designed for the research & develop-
accessible, cost-effective, and power-efficient way ment of autonomous systems in the
to integrate high-performance AI. Explore fields of human-robot interaction (HRI),
applications including process control, security, SLAM & transportation. Due to the four
home automation, and robotics! legs, as well as the 12DOF, this robot can
www.elektor.com/20879 handle a variety of different terrains.
www.elektor.com/20357
Raspberry Pi AI Camera
The Raspberry Pi AI Camera is a
compact camera module based on the
Sony IMX500 Intelligent Vision Sensor.
The IMX500 combines a 12 MP CMOS
image sensor with on-board inferenc-
ing acceleration for various common
neural network models, allowing users
to develop sophisticated vision-based AI
applications without requiring a separate
BeagleY-AI SBC with GPU, accelerator.
DSP and AI Accelerators www.elektor.com/20953
BeagleY-AI is a low-cost, open-source,
Waveshare Jetson Orin Nano
and powerful 64-bit quad-core single-
AI Development Kit
board computer, equipped with a GPU,
This AI Edge Computing Development
DSP, and vision/deep learning accel-
Kit is based on the Jetson Orin Nano
erators, designed for developers and
Module providing rich peripheral inter-
makers. Users can take advantage of
faces such as M.2, DP, USB, etc.
BeagleBoard.org’s provided Debian
The kit also comes with a pre-installed
Linux software images, which include a
AW-CB375NF wireless network card
built-in development environment.
that supports Bluetooth 5.0 and dual-
www.elektor.com/20991
band WIFI, with two additional PCB
antennas, for providing high-speed and
reliable wireless network connection and
Programming Voice-controlled IoT Bluetooth communication.
Applications with Alexa and Raspberry Pi www.elektor.com/20762
This book is divided into two parts: creating Alexa skills
and designing Internet of Things (IoT) devices using a
Raspberry Pi. It covers topics like Alexa skill develop-
ment, in-skill purchasing, and using AWS Lambda, as
well as building smart home devices controlled by Alexa.
Readers also learn about MQTT messaging, creating
proactive notifications, and turning a Raspberry Pi into a
stand-alone Alexa device.
www.elektor.com/20400
Guest-Edited AI Edition 47
Join the
Elektor C mmunity
Take out a G O L D membership
membership!
www.elektormagazine.com/member