Get (Ebook) Introduction to IoT with Machine Learning and Image Processing using Raspberry Pi by Shrirang Ambaji Kulkarni, Varadrah P. Gurupur, Steven L. Fernandes ISBN 9781138543522, 1138543527 free all chapters
Get (Ebook) Introduction to IoT with Machine Learning and Image Processing using Raspberry Pi by Shrirang Ambaji Kulkarni, Varadrah P. Gurupur, Steven L. Fernandes ISBN 9781138543522, 1138543527 free all chapters
https://ebooknice.com/product/biota-grow-2c-gather-2c-cook-6661374
ebooknice.com
https://ebooknice.com/product/iot-machine-learning-applications-in-
telecom-energy-and-agriculture-with-raspberry-pi-and-arduino-using-
python-50195440
ebooknice.com
https://ebooknice.com/product/matematik-5000-kurs-2c-larobok-23848312
ebooknice.com
https://ebooknice.com/product/sat-ii-success-
math-1c-and-2c-2002-peterson-s-sat-ii-success-1722018
ebooknice.com
(Ebook) Natural Language Processing Recipes: Unlocking Text Data with
Machine Learning and Deep Learning Using Python by Akshay Kulkarni,
Adarsha Shivananda ISBN 9781484273500, 1484273508
https://ebooknice.com/product/natural-language-processing-recipes-
unlocking-text-data-with-machine-learning-and-deep-learning-using-
python-34204404
ebooknice.com
https://ebooknice.com/product/raspberry-pi-3-cookbook-for-python-
programmers-unleash-the-potential-of-raspberry-pi-3-with-
over-100-recipes-7217158
ebooknice.com
https://ebooknice.com/product/raspberry-pi-image-processing-
programming-with-numpy-scipy-matplotlib-and-opencv-44512010
ebooknice.com
https://ebooknice.com/product/sensor-projects-with-raspberry-pi-
internet-of-things-and-digital-image-processing-23627084
ebooknice.com
Introduction to IoT with
Machine Learning and
Image Processing using
Raspberry Pi
Introduction to IoT with
Machine Learning and
Image Processing using
Raspberry Pi
Reasonable efforts have been made to publish reliable data and information, but the author and
publisher cannot assume responsibility for the validity of all materials or the consequences of their
use. The authors and publishers have attempted to trace the copyright holders of all material
reproduced in this publication and apologize to copyright holders if permission to publish in this
form has not been obtained. If any copyright material has not been acknowledged please write and
let us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced,
transmitted, or utilized in any form by any electronic, mechanical, or other means, now known or
hereafter invented, including photocopying, microfilming, and recording, or in any information
storage or retrieval system, without written permission from the publishers.
For permission to photocopy or use material electronically from this work, access www.copyright.com
or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-
750-8400. For works that are not available on CCC please contact [email protected]
Trademark notice: Product or corporate names may be trademarks or registered trademarks, and
are used only for identification and explanation without intent to infringe.
Contents
Authors, vii
CHAPTER 1 ■ Introduction 1
BIBLIOGRAPHY, 151
INDEX, 153
v
Authors
vii
CHAPTER 1
Introduction
I n the last three decades, technology has changed the way we live our
lives. This happens to be a universally accepted truth. In this book, we
attempt to illustrate the use of a new technology that has changed the
world of communication, computing and computing education. Interest-
ingly, the name of this technology coincides with that of a famous dessert
named Raspberry Pie. Raspberry Pi is a single board computer developed
in the United Kingdom. Incidentally, the organization that started this is
known as the Raspberry Pi Foundation. This was first launched in
the year 2012.
By the year 2015, Raspberry Pi had gained wide-scale popularity. One of
the key features of this technology was its size and adaptability. In some
strange ways, Raspberry Pi was the panacea the world of technology was
dreaming of. To build on this idea of a tiny computer, one must consider
the fact that more than a decade ago you would have computer programs
running on desktops wired to electromechanical systems that would use
them. The advent of the Raspberry Pi enables the community of technology
developers to innovate handheld devices than can encompass the power of
regular computers. Our intention in writing this book is twofold: a) we
want to provide a basic understanding of how a Raspberry Pi can be used
for simple applications, and b) we want to provide fundamental informa-
tion on how a Raspberry Pi can be used to advance innovations in machine
learning and image recognition.
While providing fundamental information on Raspberry Pi, we will
help students comprehend the necessary information required to develop
1
2 ■ IoT using Raspberry Pi
applications and devices. These devices and applications can have a wide
range of applications such as networking devices, using devices and
applications related to privacy and security, creating medical applications
and developing sensors. The authors believe that this range of applica-
tions will help the scientific community adapt Raspberry Pi for use in
some of their projects and thereby enhance its usability.
Additionally, the authors are attempting to present information on
how Raspberry Pi can successfully implement machine learning and
image processing. The information presented in this book will help the
community of researchers synthesize new scientific methods, algo-
rithms, devices and other forms of technology into a wide range of
application domains. The authors envision Raspberry Pi advancing the
development of science and technology across various user domains
such as medicine, security, communication, and the military. Last but
not least, it is our attempt to have this book used as study material for
courses teaching students about using Raspberry Pi. It is our under-
standing that Raspberry Pi can be used extensively in healthcare informa-
tion systems.
In this book, the authors present a transformative interdisciplinary
perspective of Raspberry Pi usage. This idea is based on the philosophy of
transformative transdisciplinary perspective presented by the founding
fathers of Society for Design and Process Science [1]. This philosophy is
based on bringing about a positive transformative change to one domain
by making changes or improvements in another. This philosophy is
applicable to Raspberry Pi because rapid improvements in Raspberry Pi
and its applicability will facilitate and create a rostrum for improvements
in all the domains in which this device can be used. One example will be
the implementation of machine learning algorithms that can aid image
processing. In this book, the authors have dwelled on some of the
fundamental programming concepts that are needed for image analysis
and machine learning. This is another very important reason this book is
needed for its targeted audience.
While we engage ourselves in recognizing the importance of the Rasp-
berry Pi, it is also important to note that Raspberry Pi has competitors or
alternatives available in the market. A brief summary of these alternatives is
listed in Table 1.1.
This book is divided into five chapters. The first chapter provides some
introductory material on Raspberry Pi and a brief introduction to the
Introduction ■ 3
authors. The second chapter explains different types of Raspberry Pis and
provides the reader with important information on the slots and other
necessary elements of the Raspberry Pi. An explanation on these elements
or parts is essential from a usability perspective. It also provides instruc-
tions on installing the operating system Raspbian [3] on Raspberry Pi.
Additionally, it provides some information on peripheral devices and the
ways in which they can be used with the Raspberry Pi.
The importance of using Raspbian dwells in the idea that installing and
using this operating system is a necessary step in the synthesis of systems
and applications. Raspbian is a freely available operating system for the
Raspberry Pi. It is important to note that Raspbian is not affiliated with the
Raspberry Pi Foundation. Raspbian is a community-funded development
effort as was the case in the early days of the Linux operating system.
Interestingly, Raspbian is a Linux distribution built with the Linux operating
system. Raspbian was first released in the year 2012.
The third chapter explains the elements of Python programming [4]
that are essential with respect to using Raspberry Pi. Here the authors
dwell on esoteric programming details that are needed for successful
Raspberry Pi application. These details include matrix operations, Cholesky
4 ■ IoT using Raspberry Pi
REFERENCES
[1] Society for Design and Process Science Official Website [Online]. Available:
www.sdpsnet.org/sdps/. Accessed: 09/24/2019.
[2] Electromaker [Online]. Available: www.electromaker.io/blog/article/10-
best-raspberry-pi-alternatives. Accessed: 09/24/2019.
[3] Raspbian [Online]. Available: www.raspbian.org/RaspbianImages
[4] S.A. Kulkarni, Problem Solving and Python Programming, YesDee Publish-
ers, Chennai, India, 2017.
CHAPTER 2
Raspberry Pi Unraveled
2.0 RASPBERRY PI
Raspberry Pi is an Advanced RISC Machines (ARM)-processed, credit-
card sized computer. It was developed by the Raspberry Pi Foundation
in the United Kingdom (UK).
7
8 ■ IoT using Raspberry Pi
and the other is the physical numbering. The GPIO numbering refers to
the Broadcom numbering on System on Chip, whereas the physical
numbering refers to the 40 pins specified on the Raspberry Pi Board.
Step 3: raspi-config
$ sudo raspi-config
You will see the following screen (Figure 2.9). Choose the interfacing options.
Press Enter to move into an option and arrow keys to move up/down.
Tab to select the options like <finish>.
Step 3.1: Change the user password. The default login is pi and
password is raspberry.
Step 3.2: Enable boot to Desktop.
Step 3.3: Internationalization options
Step 3.3.1: Change-locale: select a language.
Step 3.3.2: Change time zone.
Step 3.3.3: Change keyboard layout. QWERTY is the
default.
1. Smart Home: The Smart Home is the most potent application for
IoT. You can control air conditioners, refrigerators, microwave
ovens, lighting and entertainment systems through IoT-based con-
trol systems.
2. Wearable devices: Monitoring human health parameters like heart-
beat, blood pressure and other vitals is possible through wearable
IoT devices. The constraint on these devices is that they must be
small and energy efficient.
3. Farming: Farmers are at times challenged to monitor crops and
livestock at remote farm areas. Now this is possible through IoT.
Also, detecting diseases of crops and water usage can be controlled
through IoT devices.
4. Industrial IoT: It has been now realized that IoT has a host of
applications across different industries like manufacturing, oil and
gas and energy. IoT helps industries in the automation and optimi-
zation of resources.
EXERCISES
1. Show how to make a headless Raspberry Pi installation.
2. Explain why Secure Shell (SSH) is disabled from Raspberry Pi 3
onwards.
3. What type of file system is preferred on the SD card used for
uploading the Raspberry Pi operating system?
4. Discuss the various operating systems available for Raspberry Pi
along with their advantages and disadvantages.
18 ■ IoT using Raspberry Pi
REFERENCE
[1] Gartner, https://www.gartner.com/en/newsroom/press-releases/2019-08-
29-gartner-says-5-8-billion-enterprise-and-automotive-io, 2019.
CHAPTER 3
3.1 INTRODUCTION
Python is one of the most popular languages for Machine Learning. One
of the dominant reasons for the popularity of Python is its rich support
of libraries (see Table 3.1).
3.2 PYTHON
3.2.1 What Is Python?
• Python was proposed by Guido van Rossum in the late 1980s.
• It is a simple but powerful high-level programming language.
• It supports procedural and object-oriented concepts.
• Python code is interpreted rather than compiled.
19
20 ■ IoT using Raspberry Pi
Numeric int
long
float
complex
bool
Sequence str
list
tuple
Sets set
frozen set
Mapping dict
To determine the data type of the variable use the type() function in
Python. Python program: datatype.py as illustrated in Figure 3.6.
while expression:
statement
The while loop iterates as long as the condition is True. The Statement
can be a single statement or block of statements.
Example: Python program while_loop.py as seen in Figure 3.12.
FIGURE 3.16 Python Program to Demonstrate for loop in the Reverse Manner.
30 ■ IoT using Raspberry Pi
FIGURE 3.19 Output of Python Program for else with while loop.
The else statement is clubbed with the for loop in the case in which the
for loop has been exhausted by iterating with all elements in the sequence.
For example, consider the Python program illustrated in Figure 3.20.
FIGURE 3.20 Python Program to Demonstrate else in Combination with for loop.
FIGURE 3.21 Output of Python Program for Else with for loop.
32 ■ IoT using Raspberry Pi
len(lst)
Output: 4
• list.reverse() reverses the elements of the list.
lst=['a', 'b', 'c', 'd']
lst.reverse()
lst=['d', 'c', 'b', 'a']
• list.sort() sorts the elements of the list in ascending order.
lst=['d', 'c', 'b', 'a']
lst.sort()
lst= ['a', 'b', 'c', 'd']
FIGURE 3.24 Python Program to Demonstrate a Function That Can Accept and
Return a Value.
It provides support for linear algebra operations and allows Python code
to interact with C and C++.
How to use NumPy
The convention is to use NumPy with the command as illustrated in
Figure 3.26.
"You're a very gallant young lady, miss, and I'm proud and
honoured to make your acquaintance."
With shining eyes Christine looked from one to the other of them.
"I knew that you wouldn't fail us," she said. Then, coming
towards me, she added eagerly: "But what are we waiting for? Why
don't we start at once?"
"I was kept for an hour at that cursed office. There was some
Admiralty business that had to be attended to."
"We have still time." she said. "If we can catch them up before
they get to Holland——"
"Never fear, miss," he rejoined. "We'll bring him back to you and
the diamonds as well."
"I am coming too," said Christine quietly.
"Haven't you got any shoes?" he asked. "You can't go through the
shrubbery like that."
There was very little mist left, and the moon, although
occasionally obscured by clouds, was now shining brightly. We
passed through the iron gate and entered the shrubbery, where I
showed them the broken wire which had been the cause of my
downfall. Then, step by step, we moved cautiously forward along the
winding path, until a glimmer of light in front of us showed that the
trees were coming to an end.
We could see the launch lying out in the tideway, and a dark
figure, silhouetted sharply against the water, standing on guard over
a small dinghy.
At the sound of his voice the sailor wheeled round quickly; and
then, seeing us advancing across the grass, drew himself up to the
salute.
Within five minutes of our feet touching the deck the anchor was
hauled in, and we were heading out into the open estuary, with the
black water rippling past our stern.
I nodded. "If you've got such a thing as a spare gun," I said, "I'll
borrow that too."
"Not for me, thank you," he replied. "If Dr. Manning wants to
argue I've got an old friend here who'll do all the talking that's
necessary."
"I'm not surprised to hear it, miss," was the answer. "All the
same, if it comes to a shooting match, the proper place for you is in
the cabin."
"Of course we shall," I answered. "It's not likely that they can do
more than twenty, and Bobby can knock nearly forty out of this old
jigger." I squeezed her hand comfortingly in the darkness.
As there was no sign of our quarry it was clear that she was
already round the point. Manning had doubtless seen Bobby's launch
returning up the estuary and had wasted no time in getting away
from "The Laurels" directly he had discovered Christine's flight. At
the lowest computation he must now be at least six miles ahead of
us. Provided the moonlight held, however, he would still be in sight
by the time he reached the bar, and I glanced anxiously at heavy
masses of cloud which were gathering ominously from the south-
east.
Bit by bit the coast opened out on our right, until at last we were
almost opposite the big clump of trees which marks the extreme end
of the southern shore.
There, not half a mile ahead of us, was the launch. She was lying
broadside on under the full light of the moon, and one glance was
sufficient to show me she had broken down. Even at that distance I
could make out two figures working frantically at the engines and
another huddled shape in the bows.
"We've got 'em!" roared Bobby, above the throb of the pistons.
I had rather it had been the other way on, but there was no time
for arguing.
*****
For a little while I thought that I was still dreaming. Then the low
murmur of voices became so persistent that at last, with a
tremendous effort, I managed to open my eyes.
There was the scrape of a chair, and the next moment Bobby and
Christine were standing beside the bed.
"It's all right, old lad," said the former soothingly. "We're both
here."
Christine sat down beside me, and very tenderly took my hand in
hers.
"You are back on the island, dear, in your own room. There's
nothing to be anxious about or worried over. It's all finished, and we
are just here together—you and I and Bobby."
"I remember now," I said. "I stopped a bullet, didn't I? I've a sort
of recollection of seeing a lot of stars, and after that everything's a
blank."
"Tell me," she whispered, "is your head hurting you very much?"
"I don't know if Manning saw you fall," continued Bobby, "but if so
it was the last thing he did see on this earth. We all fired directly he
raised his hand. He got three bullets, one from Christine, one from
Campbell, and one from me. It will be a very interesting point as to
which of us killed him."
"You laid Craill out all right. At the present moment he's in the
Pen Mill Police Station nursing a sick elbow."
"We found my uncle lying dead on the deck," she whispered. "Dr.
Ross had always told me that any great shock or excitement——"
Her voice faltered, and, breaking into a pitiful little sob, she buried
her face in her hands.
"My poor darling," I said hoarsely. "I'd have given anything in the
world——"
With a brave effort she raised her head and brushed away the
tears which were running down her cheeks.
"I know," she said, "I know how you feel. I can't help crying, it's
all so sad and terrible, but even if it were possible I don't think I
would wish him to be alive. It nearly broke my heart to see him as
he was. Now at least he is at peace."
"There isn't much more to tell," said Bobby quietly. "We towed the
launch to Pen Mill, and Campbell went ashore and rang up the
police. The Head Constable came over at once and brought the
doctor with him. There was the devil of a fuss, as you can imagine.
Fortunately, however, the old boy knew all about Campbell, and after
a lot of jaw we were allowed to bring you back here and put you to
bed. It was nearly midnight by then, and we've been taking turns
sitting up with you ever since."
"Close on twelve."
"It's probably the doctor," she said. "He promised to come over as
soon as he was free."
"I'll do nothing of the sort," began Bobby indignantly. "If you like
to give Campbell—" He stopped short at the sound of returning
footsteps, and a moment later Christine entered the room.
"A man has called with a message from Mr. Campbell," she said.
"He wants you to go over to the hotel at once."
*****
"I suppose we must let him have his way," I said. "We can't very
well refuse after all he's done for us."
"I don't know why it is," she said helplessly, "I feel as if I wanted
to laugh and cry at the same time."
I stretched out my hand and drew her down on to the bed beside
me.
"It's only this house, dear heart," I said gently. "As soon as it's all
over we'll go away together and——"
"Oh, but your shoulder!" she faltered. "Your poor shoulder! The
doctor said——"
THE END
*** END OF THE PROJECT GUTENBERG EBOOK GREENSEA ISLAND:
A MYSTERY OF THE ESSEX COAST ***
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebooknice.com