Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
11 views

Building Computer Vision Applications Using Artificial Neural Networks: With Step-by-Step Examples in OpenCV and TensorFlow with Python 1st Edition Shamshad Ansari - Get instant access to the full ebook content

The document provides information about various eBooks available for download, particularly focusing on 'Building Computer Vision Applications Using Artificial Neural Networks' by Shamshad Ansari. It includes links to multiple editions and related titles in the field of computer vision and artificial intelligence. The content also outlines the structure of the book, including chapters on image processing, machine learning, and deep learning concepts.

Uploaded by

kreslnsixb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
11 views

Building Computer Vision Applications Using Artificial Neural Networks: With Step-by-Step Examples in OpenCV and TensorFlow with Python 1st Edition Shamshad Ansari - Get instant access to the full ebook content

The document provides information about various eBooks available for download, particularly focusing on 'Building Computer Vision Applications Using Artificial Neural Networks' by Shamshad Ansari. It includes links to multiple editions and related titles in the field of computer vision and artificial intelligence. The content also outlines the structure of the book, including chapters on image processing, machine learning, and deep learning concepts.

Uploaded by

kreslnsixb
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 72

Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.

com

Building Computer Vision Applications Using


Artificial Neural Networks: With Step-by-Step
Examples in OpenCV and TensorFlow with Python 1st
Edition Shamshad Ansari
https://ebookmeta.com/product/building-computer-vision-
applications-using-artificial-neural-networks-with-step-by-
step-examples-in-opencv-and-tensorflow-with-python-1st-
edition-shamshad-ansari/

OR CLICK HERE

DOWLOAD EBOOK

Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Building Computer Vision Applications Using Artificial


Neural Networks, 2nd Edition Shamshad Ansari

https://ebookmeta.com/product/building-computer-vision-applications-
using-artificial-neural-networks-2nd-edition-shamshad-ansari/

ebookmeta.com

Learn OpenCV with Python by Examples Implement Computer


Vision Algorithms Provided by OpenCV with Python for Image
Processing Object Detection and Machine Learning 2nd
Edition James Chen
https://ebookmeta.com/product/learn-opencv-with-python-by-examples-
implement-computer-vision-algorithms-provided-by-opencv-with-python-
for-image-processing-object-detection-and-machine-learning-2nd-
edition-james-chen/
ebookmeta.com

Learn OpenCV with Python by Examples 2nd Edition James


Chen

https://ebookmeta.com/product/learn-opencv-with-python-by-
examples-2nd-edition-james-chen/

ebookmeta.com

Ultimate Star Wars New Edition The Definitive Guide to the


Star Wars Universe Adam Bray

https://ebookmeta.com/product/ultimate-star-wars-new-edition-the-
definitive-guide-to-the-star-wars-universe-adam-bray/

ebookmeta.com
Black Light Disciplined Black Light Series Book 29 1st
Edition Livia Grant

https://ebookmeta.com/product/black-light-disciplined-black-light-
series-book-29-1st-edition-livia-grant-2/

ebookmeta.com

Breaking the Zero Sum Game Transforming Societies Through


Inclusive Leadership 1st Edition Aldo Boitano

https://ebookmeta.com/product/breaking-the-zero-sum-game-transforming-
societies-through-inclusive-leadership-1st-edition-aldo-boitano/

ebookmeta.com

States of Exception: Law, History, Theory 1st Edition


Cosmin Cercel (Editor)

https://ebookmeta.com/product/states-of-exception-law-history-
theory-1st-edition-cosmin-cercel-editor/

ebookmeta.com

Data Management at Scale, Second Edition Piethein


Strengholt

https://ebookmeta.com/product/data-management-at-scale-second-edition-
piethein-strengholt/

ebookmeta.com

Midnight Ice Complete Series Kaitlyn Davis

https://ebookmeta.com/product/midnight-ice-complete-series-kaitlyn-
davis/

ebookmeta.com
Glencoe Short Stories 3 1st Edition Jeffrey D. Wilhelm Et
Al

https://ebookmeta.com/product/glencoe-short-stories-3-1st-edition-
jeffrey-d-wilhelm-et-al/

ebookmeta.com
Building Computer
Vision Applications
Using Artificial Neural
Networks
With Step-by-Step Examples in
OpenCV and TensorFlow with Python

Shamshad Ansari

www.allitebooks.com
Building Computer Vision
Applications Using
Artificial Neural Networks
With Step-by-Step Examples
in OpenCV and TensorFlow
with Python

Shamshad Ansari

www.allitebooks.com
Building Computer Vision Applications Using Artificial Neural Networks: With
Step-by-Step Examples in OpenCV and TensorFlow with Python
Shamshad Ansari
Centreville, VA, USA

ISBN-13 (pbk): 978-1-4842-5886-6 ISBN-13 (electronic): 978-1-4842-5887-3


https://doi.org/10.1007/978-1-4842-5887-3

Copyright © 2020 by Shamshad Ansari


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Celestin Suresh John
Development Editor: Matthew Moodie
Coordinating Editor: Aditee Mirashi
Cover designed by eStudioCalamar
Cover image designed by Pixabay
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member
(owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a
Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/978-1-4842-5886-6. For more
detailed information, please visit www.apress.com/source-code.
Printed on acid-free paper

www.allitebooks.com
In God we trust.
To my wonderful parents, Abdul Samad and
Nazhat Parween, who always corrected my mistakes and
raised me to become a good person.
To my lovely wife, Shazia, and our two beautiful daughters,
Dua and Erum. Without their love and support, this book
would not have been possible.

www.allitebooks.com
Table of Contents
About the Author�����������������������������������������������������������������������������������������������������xv

About the Technical Reviewer�������������������������������������������������������������������������������xvii


Acknowledgments��������������������������������������������������������������������������������������������������xix

Introduction������������������������������������������������������������������������������������������������������������xxi

Chapter 1: Prerequisites and Software Installation�������������������������������������������������� 1


Python and PIP������������������������������������������������������������������������������������������������������������������������������ 2
Installing Python and PIP on Ubuntu���������������������������������������������������������������������������������������� 2
Installing Python and PIP on macOS���������������������������������������������������������������������������������������� 2
Installing Python and PIP on CentOS 7������������������������������������������������������������������������������������ 3
Installing Python and PIP on Windows������������������������������������������������������������������������������������� 3
virtualenv�������������������������������������������������������������������������������������������������������������������������������������� 3
Installing and Activating virtualenv����������������������������������������������������������������������������������������� 4
TensorFlow������������������������������������������������������������������������������������������������������������������������������������ 5
Installing TensorFlow��������������������������������������������������������������������������������������������������������������� 5
PyCharm IDE��������������������������������������������������������������������������������������������������������������������������������� 5
Installing PyCharm������������������������������������������������������������������������������������������������������������������ 6
Configuring PyCharm to Use virtualenv����������������������������������������������������������������������������������� 6
OpenCV����������������������������������������������������������������������������������������������������������������������������������������� 7
Working with OpenCV�������������������������������������������������������������������������������������������������������������� 7
Installing OpenCV4 with Python Bindings�������������������������������������������������������������������������������� 8
Additional Libraries����������������������������������������������������������������������������������������������������������������������� 8
Installing SciPy������������������������������������������������������������������������������������������������������������������������ 8
Installing Matplotlib����������������������������������������������������������������������������������������������������������������� 8

www.allitebooks.com
Table of Contents

Chapter 2: Core Concepts of Image and Video Processing��������������������������������������� 9


Image Processing������������������������������������������������������������������������������������������������������������������������� 9
Image Basics������������������������������������������������������������������������������������������������������������������������������� 10
Pixels������������������������������������������������������������������������������������������������������������������������������������������ 10
Pixel Color������������������������������������������������������������������������������������������������������������������������������ 10
Coordinate Systems�������������������������������������������������������������������������������������������������������������������� 11
Python and OpenCV Code to Manipulate Images������������������������������������������������������������������������ 14
Program: Loading, Exploring, and Showing an Image����������������������������������������������������������� 15
Program: OpenCV Code to Access and Manipulate Pixels����������������������������������������������������� 17
Drawing��������������������������������������������������������������������������������������������������������������������������������������� 18
Drawing a Line on an Image�������������������������������������������������������������������������������������������������� 18
Drawing a Rectangle on an Image���������������������������������������������������������������������������������������� 21
Drawing a Circle on an Image����������������������������������������������������������������������������������������������� 25
Summary������������������������������������������������������������������������������������������������������������������������������������ 26

Chapter 3: Techniques of Image Processing����������������������������������������������������������� 27


Transformation���������������������������������������������������������������������������������������������������������������������������� 27
Resizing��������������������������������������������������������������������������������������������������������������������������������� 28
Translation����������������������������������������������������������������������������������������������������������������������������� 32
Rotation��������������������������������������������������������������������������������������������������������������������������������� 34
Flipping���������������������������������������������������������������������������������������������������������������������������������� 37
Cropping�������������������������������������������������������������������������������������������������������������������������������� 40
Image Arithmetic and Bitwise Operations����������������������������������������������������������������������������������� 42
Addition��������������������������������������������������������������������������������������������������������������������������������� 43
Subtraction���������������������������������������������������������������������������������������������������������������������������� 46
Bitwise Operations���������������������������������������������������������������������������������������������������������������� 52
Masking�������������������������������������������������������������������������������������������������������������������������������������� 58
Splitting and Merging Channels�������������������������������������������������������������������������������������������������� 61
Noise Reduction Using Smoothing and Blurring������������������������������������������������������������������������� 64
Mean Filtering or Averaging�������������������������������������������������������������������������������������������������� 64
Gaussian Filtering������������������������������������������������������������������������������������������������������������������ 67

vi
Table of Contents

Median Blurring��������������������������������������������������������������������������������������������������������������������� 69
Bilateral Blurring������������������������������������������������������������������������������������������������������������������� 71
Binarization with Thresholding��������������������������������������������������������������������������������������������������� 74
Simple Thresholding�������������������������������������������������������������������������������������������������������������� 74
Adaptive Thresholding����������������������������������������������������������������������������������������������������������� 77
Otsu’s Binarization����������������������������������������������������������������������������������������������������������������� 79
Gradients and Edge Detection����������������������������������������������������������������������������������������������������� 82
Sobel Derivatives (cv2.Sobel() Function)������������������������������������������������������������������������������� 82
Laplacian Derivatives (cv2.Laplacian() Function)������������������������������������������������������������������ 87
Canny Edge Detection����������������������������������������������������������������������������������������������������������� 89
Contours�������������������������������������������������������������������������������������������������������������������������������������� 90
Drawing Contours������������������������������������������������������������������������������������������������������������������ 93
Summary������������������������������������������������������������������������������������������������������������������������������������ 94

Chapter 4: Building a Machine Learning–Based Computer Vision System������������� 95


Image Processing Pipeline���������������������������������������������������������������������������������������������������������� 95
Feature Extraction����������������������������������������������������������������������������������������������������������������������� 97
How to Represent Features��������������������������������������������������������������������������������������������������� 98
Color Histogram��������������������������������������������������������������������������������������������������������������������� 99
Histogram Equalizer������������������������������������������������������������������������������������������������������������ 106
GLCM����������������������������������������������������������������������������������������������������������������������������������� 109
HOGs������������������������������������������������������������������������������������������������������������������������������������ 115
LBP�������������������������������������������������������������������������������������������������������������������������������������� 121
Feature Selection���������������������������������������������������������������������������������������������������������������������� 128
Filter Method����������������������������������������������������������������������������������������������������������������������� 128
Wrapper Method������������������������������������������������������������������������������������������������������������������ 129
Embedded Method�������������������������������������������������������������������������������������������������������������� 130
Model Training��������������������������������������������������������������������������������������������������������������������������� 130
How to Do Machine Learning���������������������������������������������������������������������������������������������� 130
Supervised Learning������������������������������������������������������������������������������������������������������������ 131
Unsupervised Learning�������������������������������������������������������������������������������������������������������� 132

vii
Table of Contents

Model Deployment�������������������������������������������������������������������������������������������������������������������� 133


Summary���������������������������������������������������������������������������������������������������������������������������������� 135

Chapter 5: Deep Learning and Artificial Neural Networks������������������������������������ 137


Introduction to Artificial Neural Networks��������������������������������������������������������������������������������� 137
Perceptron��������������������������������������������������������������������������������������������������������������������������� 140
Multilayer Perceptron���������������������������������������������������������������������������������������������������������� 141
What Is Deep Learning?������������������������������������������������������������������������������������������������������ 143
Deep Learning or Multilayer Perceptron Architecture��������������������������������������������������������� 143
Activation Functions������������������������������������������������������������������������������������������������������������ 146
Feedforward������������������������������������������������������������������������������������������������������������������������ 154
Error Function���������������������������������������������������������������������������������������������������������������������� 154
Optimization Algorithms������������������������������������������������������������������������������������������������������ 158
Backpropagation����������������������������������������������������������������������������������������������������������������� 164
Introduction to TensorFlow�������������������������������������������������������������������������������������������������������� 165
TensorFlow Installation�������������������������������������������������������������������������������������������������������� 166
How to Use TensorFlow������������������������������������������������������������������������������������������������������� 166
Tensor���������������������������������������������������������������������������������������������������������������������������������� 166
Variable�������������������������������������������������������������������������������������������������������������������������������� 167
Constant������������������������������������������������������������������������������������������������������������������������������ 167
Our First Computer Vision Model with Deep Learning: Classification of Handwritten Digits���� 169
Model Evaluation����������������������������������������������������������������������������������������������������������������������� 178
Overfitting���������������������������������������������������������������������������������������������������������������������������� 179
Hyperparameters���������������������������������������������������������������������������������������������������������������������� 184
TensorBoard������������������������������������������������������������������������������������������������������������������������ 185
Experiments for Hyperparameter Tuning����������������������������������������������������������������������������� 185
Saving and Restoring Model����������������������������������������������������������������������������������������������������� 189
Save Model Checkpoints During Training���������������������������������������������������������������������������� 190
Manually Save Weights������������������������������������������������������������������������������������������������������� 193
Load the Saved Weights and Retrain the Model������������������������������������������������������������������ 193
Saving the Entire Model������������������������������������������������������������������������������������������������������ 193

viii
Table of Contents

Retraining the Existing Model���������������������������������������������������������������������������������������������� 194


Using a Trained Model in Applications��������������������������������������������������������������������������������� 194
Convolution Neural Network����������������������������������������������������������������������������������������������������� 194
Architecture of CNN������������������������������������������������������������������������������������������������������������� 195
How Does CNN Work����������������������������������������������������������������������������������������������������������� 196
Summary of CNN Concepts������������������������������������������������������������������������������������������������� 201
Training a CNN Model: Pneumonia Detection from Chest X-rays���������������������������������������� 202
Examples of Popular CNNs�������������������������������������������������������������������������������������������������� 213
Summary����������������������������������������������������������������������������������������������������������������������������� 217

Chapter 6: Deep Learning in Object Detection������������������������������������������������������ 219


Object Detection������������������������������������������������������������������������������������������������������������������������ 219
Intersection Over Union������������������������������������������������������������������������������������������������������������� 220
Region-Based Convolutional Neural Network��������������������������������������������������������������������������� 222
Fast R-CNN������������������������������������������������������������������������������������������������������������������������������� 224
Faster R-CNN���������������������������������������������������������������������������������������������������������������������������� 225
Region Proposal Network���������������������������������������������������������������������������������������������������� 226
Fast R-CNN�������������������������������������������������������������������������������������������������������������������������� 227
Mask R-CNN������������������������������������������������������������������������������������������������������������������������������ 227
Backbone����������������������������������������������������������������������������������������������������������������������������� 228
RPN�������������������������������������������������������������������������������������������������������������������������������������� 229
Output Head������������������������������������������������������������������������������������������������������������������������� 229
What Is the Significance of the Masks?������������������������������������������������������������������������������ 230
Mask R-CNN in Human Pose Estimation����������������������������������������������������������������������������� 230
Single-Shot Multibox Detection������������������������������������������������������������������������������������������������ 231
SSD Network Architecture��������������������������������������������������������������������������������������������������� 232
Training�������������������������������������������������������������������������������������������������������������������������������� 235
SSD Results������������������������������������������������������������������������������������������������������������������������� 238
YOLO������������������������������������������������������������������������������������������������������������������������������������������ 238
YOLO Network Design���������������������������������������������������������������������������������������������������������� 240
Limitations of YOLO������������������������������������������������������������������������������������������������������������������� 241

ix
Table of Contents

YOLO9000 or YOLOv2����������������������������������������������������������������������������������������������������������� 241


YOLOv3�������������������������������������������������������������������������������������������������������������������������������� 244
Comparison of Object Detection Algorithms����������������������������������������������������������������������������� 247
Comparison of Architecture������������������������������������������������������������������������������������������������� 247
Comparison of Performance������������������������������������������������������������������������������������������������ 248
Training Object Detection Model Using TensorFlow������������������������������������������������������������������ 249
TensorFlow on Google Colab with GPU�������������������������������������������������������������������������������� 250
Detecting Objects Using Trained Models����������������������������������������������������������������������������������� 274
Installing TensorFlow’s models Project������������������������������������������������������������������������������� 274
Code for Object Detection���������������������������������������������������������������������������������������������������� 277
Training a YOLOv3 Model for Object Detection�������������������������������������������������������������������������� 290
Installing the Darknet Framework��������������������������������������������������������������������������������������� 291
Downloading Pre-trained Convolutional Weights���������������������������������������������������������������� 292
Downloading an Annotated Oxford-IIIT Pet Dataset������������������������������������������������������������� 292
Preparing the Dataset���������������������������������������������������������������������������������������������������������� 293
Configuring the Training Input��������������������������������������������������������������������������������������������� 297
Configuring the Darknet Neural Network���������������������������������������������������������������������������� 298
Training a YOLOv3 Model����������������������������������������������������������������������������������������������������� 299
How Long the Training Should Run�������������������������������������������������������������������������������������� 301
Final Model�������������������������������������������������������������������������������������������������������������������������� 301
Detecting Objects Using a Trained YOLOv3 Model��������������������������������������������������������������������� 302
Installing Darknet to the Local Computer���������������������������������������������������������������������������� 302
Python Code for Object Detection���������������������������������������������������������������������������������������� 303
Summary���������������������������������������������������������������������������������������������������������������������������������� 307

Chapter 7: Practical Example: Object Tracking in Videos������������������������������������� 309


Preparing the Working Environment����������������������������������������������������������������������������������������� 310
Reading a Video Stream������������������������������������������������������������������������������������������������������������ 312
Loading the Object Detection Model����������������������������������������������������������������������������������������� 314
Detecting Objects in Video Frames������������������������������������������������������������������������������������������� 315
Creating a Unique Identity for Objects Using dHash����������������������������������������������������������������� 317
Using the Hamming Distance to Determine Image Similarity��������������������������������������������������� 319

x
Table of Contents

Object Tracking������������������������������������������������������������������������������������������������������������������������� 319


Displaying a Live Video Stream in a Web Browser�������������������������������������������������������������������� 322
Installing Flask�������������������������������������������������������������������������������������������������������������������� 322
Flask Directory Structure���������������������������������������������������������������������������������������������������� 322
HTML for Displaying a Video Stream����������������������������������������������������������������������������������� 323
Flask to Load the HTML Page���������������������������������������������������������������������������������������������� 324
Flask to Serve the Video Stream����������������������������������������������������������������������������������������� 324
Running the Flask Server���������������������������������������������������������������������������������������������������� 325
Putting It All Together���������������������������������������������������������������������������������������������������������������� 325
Summary���������������������������������������������������������������������������������������������������������������������������������� 336

Chapter 8: Practical Example: Face Recognition�������������������������������������������������� 337


FaceNet������������������������������������������������������������������������������������������������������������������������������������� 338
FaceNet Neural Network Architecture��������������������������������������������������������������������������������� 338
Training a Face Recognition Model������������������������������������������������������������������������������������������� 344
Checking Out FaceNet from GitHub������������������������������������������������������������������������������������� 345
Dataset�������������������������������������������������������������������������������������������������������������������������������� 345
Downloading VGGFace2 Data���������������������������������������������������������������������������������������������� 347
Data Preparation������������������������������������������������������������������������������������������������������������������ 349
Model Training��������������������������������������������������������������������������������������������������������������������� 351
Evaluation���������������������������������������������������������������������������������������������������������������������������� 353
Developing a Real-Time Face Recognition System������������������������������������������������������������������� 354
Face Detection Model���������������������������������������������������������������������������������������������������������� 354
Classifier for Face Recognition�������������������������������������������������������������������������������������������� 355
Summary���������������������������������������������������������������������������������������������������������������������������������� 360

Chapter 9: Industrial Application: Real-Time Defect Detection in Industrial


Manufacturing������������������������������������������������������������������������������������������������������ 361
Real-Time Surface Defect Detection System���������������������������������������������������������������������������� 362
Dataset�������������������������������������������������������������������������������������������������������������������������������� 362
Google Colab Notebook������������������������������������������������������������������������������������������������������� 364
Data Transformation������������������������������������������������������������������������������������������������������������ 365
Training the SSD Model������������������������������������������������������������������������������������������������������� 374

xi
Table of Contents

Exporting the Model������������������������������������������������������������������������������������������������������������ 377


Model Evaluation����������������������������������������������������������������������������������������������������������������� 378
Prediction���������������������������������������������������������������������������������������������������������������������������� 379
Real-Time Defect Detector�������������������������������������������������������������������������������������������������� 380
Image Annotations�������������������������������������������������������������������������������������������������������������������� 380
Installing VoTT��������������������������������������������������������������������������������������������������������������������� 381
Create Connections������������������������������������������������������������������������������������������������������������� 382
Create a New Project����������������������������������������������������������������������������������������������������������� 383
Create Class Labels������������������������������������������������������������������������������������������������������������� 384
Label the Images����������������������������������������������������������������������������������������������������������������� 385
Export Labels����������������������������������������������������������������������������������������������������������������������� 386
Summary���������������������������������������������������������������������������������������������������������������������������������� 387

Chapter 10: Computer Vision Modeling on the Cloud������������������������������������������� 389


TensorFlow Distributed Training������������������������������������������������������������������������������������������������ 390
What Is Distributed Training?����������������������������������������������������������������������������������������������� 390
TensorFlow Distribution Strategy���������������������������������������������������������������������������������������� 393
TF_CONFIG: TensorFlow Cluster Configuration�������������������������������������������������������������������� 398
Example Code of Distributed Training with a Parameter Server����������������������������������������������� 400
Steps for Running Distributed Training on the Cloud���������������������������������������������������������������� 404
Distributed Training on Google Cloud���������������������������������������������������������������������������������������� 406
Signing Up for GCP Access�������������������������������������������������������������������������������������������������� 406
Creating a Google Cloud Storage Bucket����������������������������������������������������������������������������� 407
Creating the GCS Bucket from the Web UI��������������������������������������������������������������������������� 407
Creating the GCS Bucket from the Cloud Shell�������������������������������������������������������������������� 409
Launching GCP Virtual Machines����������������������������������������������������������������������������������������� 410
SSH to Log In to Each VMs�������������������������������������������������������������������������������������������������� 414
Uploading the Code for Distributed Training or Cloning the GitHub Repository������������������� 415
Installing Prerequisites and TensorFlow������������������������������������������������������������������������������ 415
Running Distributed Training����������������������������������������������������������������������������������������������� 416
Distributed Training on Azure���������������������������������������������������������������������������������������������������� 417

xii
Table of Contents

Creating a VM with Multiple GPUs on Azure������������������������������������������������������������������������ 418


Installing GPU Drivers and Libraries������������������������������������������������������������������������������������ 422
Creating virtualenv and Installing TensorFlow��������������������������������������������������������������������� 424
Implementing MirroredStrategy������������������������������������������������������������������������������������������ 424
Running Distributed Training����������������������������������������������������������������������������������������������� 425
Distributed Training on AWS������������������������������������������������������������������������������������������������������ 428
Horovod������������������������������������������������������������������������������������������������������������������������������� 428
How to Use Horovod������������������������������������������������������������������������������������������������������������ 429
Creating a Horovod Cluster on AWS������������������������������������������������������������������������������������� 433
Installing Horovod���������������������������������������������������������������������������������������������������������������� 440
Running Horovod to Execute Distributed Training��������������������������������������������������������������� 441
Summary���������������������������������������������������������������������������������������������������������������������������������� 442

Index��������������������������������������������������������������������������������������������������������������������� 443

xiii
About the Author
Shamshad (Sam) Ansari is president and CEO of Accure
Inc., an artificial intelligence automation company that he
founded. He has raised Accure from startup to a sustainable
business by building a winning team and acquiring customers
from across the globe. He has technical expertise in the areas
of computer vision, machine learning, AI, cognitive science,
NLP, and big data. He architected, designed, and developed
the Momentum platform that automates AI solution
development. He is an inventor and has four US patents in the
areas of AI and cognitive computing.
Shamshad previously worked as a senior software engineer with IBM, as VP of
engineering with Orbit Solutions, and as principal architect and director of engineering
with Apixio.

xv
About the Technical Reviewer
James Baldo is an associate professor at George Mason
University in the Volgenau School of Engineering and the
director of the Data Analytics Engineering (DAEN) Program.
His 38 years as a practicing engineer has provided him
with a broad foundation of knowledge and experience
in data analytics and engineering systems. His data
analytics interests span the areas of data engineering, data
science, and data architecture with a focus on data-centric
applications. His software engineering expertise has been
in support of deploying applications to cloud-based environments and microservice
architectures. As director of the DAEN Program, he has been responsible for developing
and coordinating its new online program offering. He holds a BS in chemistry, MS in
chemistry, MS in computer engineering, and PhD in information technology/software
engineering. He enjoys canoeing, hiking, and golf, and he lives in Manassas, Virginia,
with his wife.

xvii
Acknowledgments
I decided to write this book because I wanted to achieve two objectives: build the
computer vision concepts from the ground up to an advanced level, and provide a guide
to apply the concepts in building real-world vision systems. I will demonstrate every
single concept with use cases and code examples. I have organized the topics, connected
the contents to meaningful and practical use cases, and made sure the code was working
and fully tested. It all required my undivided attention, and I could not have done it
without the support of my family. I can’t thank my wife enough for taking care of our two
daughters and keeping them occupied while I was busy writing this book. She turned
this into a positive experience for them and for me: The kids started keeping track of my
progress and celebrated every time I finished a section, subsection, or chapter. In turn,
this gave me tremendous energy and motivation that I thoroughly enjoyed while working
on this book. I just don’t know what magic my wife used to do this.
My life is indebted to Anumati Bhagi and Ashok Bhagi, who are no less than parents
to me; their love and support always motivate me.
This book is a collection of my lifetime experiences that I gained by working with
some of the greatest engineers, data scientists, and business professionals. I would
like to thank all my colleagues at Accure and all the past companies I have worked at. I
sincerely thank all my teachers, professors, and mentors who enlightened me with their
knowledge and wisdom.
It has been a great experience working with the Apress editorial team. Aditee
Marashi, the coordinating editor, has been prompt with her responses to any question
I have had. She has also been instrumental in keeping track of the schedule. Hats off to
her. It’s been awesome working with Mathew Moodie, the development editor. Thank
you, Aditee and Matt.
My special thanks go to John Celestine, the senior editor. He is a thorough,
thoughtful, and fast decision-maker. Thank you, John, for believing in me. Thanks to
Apress for publishing this book.

xix
Acknowledgments

Professor James Baldo was the most valuable contributor to the book. As a technical
reviewer, he executed every single line of code and made sure that they all worked. He
reviewed every single word of the book, cross-checked references, and provided some
key suggestions that made this book much more valuable than I ever imagined. Thank
you, Professor Baldo.
Finally, I would like to thank the readers of this book. I would love to hear from you
all. Please send your comments, suggestions, and questions to ansarisam@gmail.com. As
the technology evolves, some of the code examples of this book may require updating. I
will try my best to keep all the code up-to-date at the book’s GitHub site. I look forward
to hearing from you.

xx
Introduction
For more than 20 years I have had the pleasure of working with some of the greatest
data scientists and computer vision experts. Along the way I have learned a lot,
especially the best practices of building large-scale computer vision systems. In this
book I present the learnings from my own personal experience and the experience of
people I have had opportunities to work with. I also present the work of some of the
greatest contributors and thought leaders of computer vision, even though I have not
had a chance to work with them. I have provided references to their work at appropriate
places throughout the book.
When I hire new engineers and scientists, one of my biggest challenges has been
to provide them with systematic training so that they can start contributing to the
development of vision systems in the shortest possible time. There are a large number of
online resources and books available on various topics related to computer vision, and it
is easy to get lost in the piles of information they present, given that the field of computer
vision is vast and complex. In this book, I attempted to provide a structured and
systematic approach of building the key concepts and working through example code to
develop real-world computer vision systems. I hope this helps you connect the dots as
you read through the chapters. My goal is to keep this book as practical and hands-on as
possible.
This book starts with the introduction of core concepts of computer vision and
provides code examples to aid in the learning of those concepts. The code examples in
the early part of the book are mainly based on OpenCV with Python.
This book also covers the basic concepts of machine learning and gradually develops
the advanced-level concepts of artificial neural networks or deep learning. Every single
concept is followed by working code examples of real-world use cases. All machine
learning–related code examples are written in TensorFlow with Python.
In this book, there are eight real-world use cases of computer vision with working
code. These use cases are from various industries, such as healthcare, security,
surveillance, and manufacturing. I have provided line-by-line explanations to help you

xxi
Introduction

understand the code. There are three chapters dedicated to practical use cases. These
chapters demonstrate how to build the vision systems from the ground up, starting from
image/video acquisition to building a data pipeline, model training, and deployment.
Training state-of-the-art computer vision models requires a lot of hardware
resources. It is desirable and economically beneficial to train computer vision models on
a cloud infrastructure to leverage the latest hardware resources, such as GPUs, and pay-­
as-­you-go cost models. The last chapter, Chapter 10, provides step-by-step instructions
for building machine learning–based computer vision applications on the three popular
cloud infrastructures: Google Cloud Platform, Amazon AWS, and Microsoft Azure.
Though the book develops the concepts from one pixel all the way to model training
on the cloud, it has certain prerequisites. You should have a working knowledge of the
Python programming language. This book is intended to help working professionals,
programmers, data scientists, and undergraduate and graduate students gain practical
knowledge of building computer vision applications using artificial neural networks.

xxii
CHAPTER 1

Prerequisites and
Software Installation
This is a hands-on book that describes how to develop computer vision applications
in the Python programming language. In this book, you will learn how to work with
OpenCV to manipulate images and build machine learning models using TensorFlow.
OpenCV, originally developed by Intel and written in C++, is an open source
computer vision and machine learning library consisting of more than 2,500 optimized
algorithms for working with images and videos. TensorFlow is an open source
framework for high-performance numerical computation and large-scale machine
learning. It is written in C++ and provides native support for GPUs. Python is the most
widely used programming language for developing machine learning applications. It is
designed to work with C++. Both TensorFlow and OpenCV provide Python interfaces
to access their low-level functionality. Although TensorFlow and OpenCV provide
interfaces in other programming languages, such as Java, C++, and MATLAB, we will
use Python as the primary language because of its simplicity and its large community of
support.
The prerequisites for this book are practical knowledge of Python and familiarity
with NumPy and Pandas. The book assumes that you are familiar with built-in data
containers in Python, such as dictionaries, lists, sets, and tuples. Here are some
resources that may be helpful to meet the prerequisites:

• Python: https://www.w3schools.com/python/

• Pandas: https://pandas.pydata.org/docs/getting_started/
index.html
• NumPy: https://numpy.org/devdocs/user/quickstart.html

1
© Shamshad Ansari 2020
S. Ansari, Building Computer Vision Applications Using Artificial Neural Networks,
https://doi.org/10.1007/978-1-4842-5887-3_1
Chapter 1 Prerequisites and Software Installation

Before we go any further, let’s prepare our working environment and set ourselves up
for the exercises we will be doing as we move along. Here we will start by downloading
and installing the required software libraries and packages.

Python and PIP


Python is our main programming language. PIP is a package installer for Python and a
de facto standard for installing and managing Python packages. To set up our working
environment, we will begin by installing Python and PIP on our working computer. The
installation steps depend on the operating system (OS) you are using. Make sure you
follow the instructions for your OS. If you already have Python and PIP installed, ensure
that you are using Python version 3.6 or greater and PIP version 19 or greater. To check
the version number of Python, execute the following command on your terminal:

$ python3 --version

The output of this command should be something like this: Python 3.6.5.
To check the version number of PIP, execute the following command on your
terminal:

$ pip3 --version

This command should show a version number of PIP 3, for example, PIP 19.1.

Installing Python and PIP on Ubuntu


Run the following commands in your Ubuntu terminal:

sudo apt update


sudo apt install python3-dev python3-pip

Installing Python and PIP on macOS


Run the following commands on macOS:

brew update
brew install python

This will install both Python and PIP.


2
Chapter 1 Prerequisites and Software Installation

Installing Python and PIP on CentOS 7


Run the following commands on CentOS 7:

sudo yum install rh-python36


sudo yum groupinstall 'Development Tools'

Installing Python and PIP on Windows


Install the Microsoft Visual C++ 2015 Redistributable Update 3. This comes with Visual
Studio 2015 but can be installed separately by following these steps:

1. Go to the Visual Studio downloads at https://visualstudio.


microsoft.com/vs/older-downloads/.

2. Select Redistributables and Build Tools.

3. Download and install the Microsoft Visual C++ 2015


Redistributable Update 3.

Make sure long paths are enabled on Windows. Here are the instructions to do that:
https://superuser.com/questions/1119883/windows-10-enable-ntfs-long-paths-
policy-option-missing.
Install the 64-bit Python 3 release for Windows from https://www.python.org/
downloads/windows/ (select PIP as an optional feature).
If these installation instructions do not work in your situation, refer to the official
Python documentation at https://www.python.org/.

v irtualenv
virtualenv is a tool to create isolated Python environments. virtualenv creates a directory
containing all the necessary executables to use the packages that a Python project will
need. virtualenv provides the following advantages:

• virtualenv allows you to have two versions of the same library so that
both your programs continue to run. Say you have a program that
requires version 1 of a Python library and another program needs
version 2 of the same library; virtualenv will allow you to run both.

3
Chapter 1 Prerequisites and Software Installation

• virtualenv creates a useful stand-alone and self-contained


environment for your development work that could be utilized for a
production environment without needing to install dependencies.

Next, we will install virtualenv and configure the environment with all the required
software. For the remainder of the book, we will assume that our reference program
dependencies will be contained in this virtualenv.
Install virtualenv using the following PIP command (the command is the same
on all OSs):

$ sudo pip3 install -U virtualenv

This will install virtualenv system-wide.

Installing and Activating virtualenv


First, create a directory where you want to set up virtualenv. I have named this directory
cv (short for “computer vision”).

$ mkdir cv
Then create the virtualenv in this directory, cv
$ virtualenv --system-site-packages -p python3 ./cv

The following is a sample output from running this command (on my MacBook):

Running virtualenv with interpreter /anaconda3/bin/python3


Already using interpreter /anaconda3/bin/python3
Using base prefix '/anaconda3'
New python executable in /Users/sansari/cv/bin/python3
Also creating executable in /Users/sansari/cv/bin/python
Installing setuptools, pip, wheel...
done.

Activate the virtual environment using a shell-specific command.

$ source ./cv/bin/activate  # for sh, bash, ksh, or zsh

When virtualenv is active, your shell prompt is prefixed with (cv). Here’s an
example:

(cv) Shamshads-MacBook-Air:~ sansari$


4
Chapter 1 Prerequisites and Software Installation

Install packages within a virtual environment without affecting the host system
setup. Start by upgrading PIP (make sure you do not run any command as root or sudo
while in virtualenv).

$ pip install --upgrade pip

$ pip list  # show packages installed within the virtual environment

When you are done and you want to exit from virtualenv, do the following:

$ deactivate  # don't exit until you're done with your programming

T ensorFlow
TensorFlow is an open source library for numerical computation and large-scale
machine learning. You will learn more about TensorFlow in subsequent chapters. Let’s
first install it and get it ready for our deep learning exercises.

I nstalling TensorFlow
We will install the latest version of TensorFlow from PyPI (https://pypi.org/project/
tensorflow/). We will install TensorFlow for CPUs. Make sure you are in virtualenv and
run the following command:

(cv) $ pip install --upgrade tensorflow

Test your TensorFlow installation by running this command:

(cv) $ python -c "import tensorflow as tf"

If TensorFlow is successfully installed, the output should not show any errors.

P
 yCharm IDE
You can use your favorite IDE for writing and managing Python code, but for the purpose
of this book, we will use the community version of PyCharm, a Python IDE.

5
Chapter 1 Prerequisites and Software Installation

Installing PyCharm
Go to the official website of PyCharm at https://www.jetbrains.com/pycharm/
download/#section=linux, select the appropriate operating system, and click Download
(under Community Version). After the download is completed, click the downloaded
package, and follow the on-screen instructions. Here are the direct links for different
operating systems:

• Linux: https://www.jetbrains.com/pycharm/download/download-­
thanks.html?platform=linux&code=PCC

• Mac: https://www.jetbrains.com/pycharm/download/download-­
thanks.html?platform=mac&code=PCC

• Windows: ­https://www.jetbrains.com/pycharm/download/
download-thanks.html?platform=windows&code=PCC

Configuring PyCharm to Use virtualenv


Follow these steps to use the virtualenv, cv, we created earlier:

1. Launch the PyCharm IDE and select File ➤ Settings for Windows
and Linux or select PyCharm ➤ Preferences for macOS.

2. In the Settings/Preferences dialog, select Project <project name> ➤


Project Interpreter.

3. Click the icon and click Add.


4. In the left pane of the Add Python Interpreter dialog, select
Existing Environment.

5. Expand the Interpreter list and select any of the existing


interpreters. Alternatively, click and specify a path to the
Python executable in your file system, for example, /Users/
sansari/cv/bin/python3.6 (see Figure 1-1).
6. Select the checkbox “Make available to all projects,” if you want.

6
Chapter 1 Prerequisites and Software Installation

Figure 1-1. Selecting an interpreter

OpenCV
OpenCV is one of the most popular and widely used libraries for image processing. All
code examples in this book are based on OpenCV 4. Therefore, our installation steps are
for version 4 of OpenCV.

Working with OpenCV


OpenCV is written in C/C++, and because it’s platform dependent, the installation
instructions vary from OS to OS. In other words, OpenCV needs to be built for your
particular platform/OS to run smoothly. We will use Python bindings to call OpenCV for
any image processing needs.
Like any other library, OpenCV is evolving; therefore, if the following installation
instructions do not work in your case, check the official website for the exact
installation process.

7
Chapter 1 Prerequisites and Software Installation

We will take an easy route to install OpenCV 4 and Python 3 bindings using PIP. We
will install the opencv-python-contrib package from PyPI in the virtual environment
that we created previously.
So here we go!

Installing OpenCV4 with Python Bindings


Make sure you are in your virtual environment. Simply change directory to your virtualenv
directory (the cv directory we created previously) and type the following command:

$ source cv/bin/activate

Install OpenCV in a snap using the following command:

$ pip install opencv-contrib-python

Additional Libraries
There are some additional libraries that we will need as we work on some of the
examples. Let’s install and keep them in our virtualenv.

Installing SciPy
Install SciPy with the following:

$ pip install scipy

Installing Matplotlib
Install Matplotlib with the following:

$ pip install matplotlib

Please note that the libraries installed in this chapter are frequently updated. It
is strongly advised to check the official websites for updates, new versions of these
libraries, and the latest installation instructions.

8
CHAPTER 2

Core Concepts of Image


and Video Processing
This chapter introduces the building blocks of an image and describes various methods
to manipulate them. Our learning objectives in this chapter are as follows:

• To understand the smallest unit of an image (a pixel) and how colors


are represented

• To learn how pixels are organized in an image and how to access and
manipulate them

• To draw different shapes, such as lines, rectangles, and circles, on an


image

• To write code in Python and use OpenCV to work with examples to


access and manipulate images

I mage Processing
Image processing is the technique of manipulating a digital image to either get an
enhanced image or extract some useful information from it. In image processing, the
input is an image, and the output may be an image or some characteristics or features
associated with that image. A video is a series of images or frames. Therefore, the
technique of image processing also applies to video processing. In this chapter, I will
explain the core concepts of digital image processing. I will also show you how to work
with images and write code to manipulate them.

9
© Shamshad Ansari 2020
S. Ansari, Building Computer Vision Applications Using Artificial Neural Networks,
https://doi.org/10.1007/978-1-4842-5887-3_2
Chapter 2 Core Concepts of Image and Video Processing

Image Basics
A digital image is an electronic representation of an object/scene or scanned document.
The digitalization of an image means converting it into a series of numbers and storing
these numbers in a computer storage system. Understanding how these numbers are
arranged and how to manipulate them is the primary objective of this chapter. In this
chapter, I will explain what makes an image and how to manipulate it using OpenCV and
Python.

Pixels
Imagine a series of dots arranged in rows and columns, and these dots have different
colors. This is pretty much how an image is formed. The dots that form an image are
called pixels. These pixels are represented by numbers, and the values of the numbers
determine the color of a pixel. Think of an image as a grid of square cells with each cell
consisting of one pixel of a particular color. For example, a 300×400-pixel image means
that the image is organized into a grid of 300 rows and 400 columns. That means our
image has 300×400 = 120,000 pixels.

Pixel Color
A pixel is represented in two ways: grayscale and color.

Grayscale
In a grayscale image, each pixel takes a value between 0 and 255. The value 0 represents
black, and 255 represents white. The values in between are varying shades of gray. The
values close to 0 are darker shades of gray, and values closer to 255 are brighter shades of
gray.

Color
The RGB (which stands for Red, Blue, and Green) color model is one of the most popular
color representations of a pixel. There are other color models, but we will stick to RGB in
this book.

10
Chapter 2 Core Concepts of Image and Video Processing

In the RGB model, each pixel is represented as a tuple of three values, generally
represented as follows: (value for red component, value for green component, value for
blue component). Each of the three colors is represented by integers ranging from 0 to
255. Here are some examples:

(0,0,0) is a black color.

(255,0,0) is a pure red color.

(0,255,0) is a pure green color.

What color is represented by (0,0,255)?


What color is represented by (255,255,255)?
This w3school website (https://www.w3schools.com/colors/colors_rgb.asp) is a
great place to play with different combinations of RGB tuples to explore more patterns.
Explore what color is represented by each of the following tuples:

(0,0,128)

(128,0,128)

(128,128,0)

Let’s try to make yellow. Here is a clue: red and green make yellow. That means a
pure red (255), a pure green (255), and no blue (0) will make yellow. So, our RGB tuple
for yellow is (255,255,0).
Now that we have a good understanding of pixels and their color, let’s understand
how pixels are arranged in an image and how to access them. The following section will
discuss the concept of coordinate systems in image processing.

C
 oordinate Systems
Pixels in an image are arranged in the form of a grid that is made of rows and columns.
Imagine a square grid of eight rows and eight columns. This will form an 8×8 or 64-pixel
image. This may be imagined as a 2D coordinate system in which (0,0) is the top-left
corner. Figure 2-1 shows our example 8×8-pixel image.

11
Chapter 2 Core Concepts of Image and Video Processing

Figure 2-1. Pixel coordinate system

The left-top corner is the start or origin of the image coordinate system. The pixel
at the top-right corner is represented by (7,0), the bottom-left corner is (7,0), and the
bottom-right pixel is (7,7). This may be generalized as (x,y), where x is the position of the
cell from the left edge of the image and y is the vertical position down from the top edge
of the image. In Figure 2-1, the red pixel is in the fifth position from the left and fourth
from the top. Since the coordinate system begins at 0, the coordinate of the red pixel
shown in Figure 2-1 is (4,3).
To make it a little clearer, let’s imagine an image that is 8×8 pixels, with the letter H
written on it (as shown in Figure 2-3). Also, for simplicity, assume this is a grayscale
image with the letter H written in black and the rest of the area of the image in white.

Figure 2-2. Pixel coordinate system example

Remember, in the grayscale model, a black pixel is represented by 0, and a white one
is represented by 255. Figure 2-3 shows the values of each pixel within the 8×8 grid.

12
Chapter 2 Core Concepts of Image and Video Processing

Figure 2-3. Pixel matrix and values

So, what’s the value of the pixel at position (1,4)? And at position (2,2)?
I hope you now have a clear picture of how images are represented by numbers
arranged in a grid. These numbers are serialized and stored in the computer’s
storage system and rendered as an image when displayed to the screen. By now you
know how to access pixels using the coordinate system and how to assign colors to
these pixels.
We have established a solid foundation and learned the basic concepts of image
representation. Let’s get ourselves some hands-on practice with some Python and
OpenCV coding. In the following section, I will show you, step-by-step, how to write
code to load images from the computer’s disk, access pixels, manipulate them, and write
them back to the disk. Without further ado, let’s dive in!

13
Chapter 2 Core Concepts of Image and Video Processing

Python and OpenCV Code to Manipulate Images


OpenCV represents the pixel values of an image as a NumPy array. (Not familiar with
NumPy? You can find a “getting started” tutorial at https://numpy.org/devdocs/user/
quickstart.html). In other words, when you load an image, OpenCV creates a NumPy
array. The pixel values can be obtained from NumPy by simply supplying the (x,y)
coordinates.
When you give the (x,y) coordinates, NumPy will return the values of colors of the
pixel at those coordinates as follows:

For a grayscale image, the returned value from NumPy will be a


single value between 0 and 255.

For a color image, the returned value from NumPy will be a tuple
for red, green, and blue. Note that OpenCV maintains the RGB
sequence in the reverse order. Remember this important feature
of OpenCV to avoid any confusion while working with OpenCV.

In other words, OpenCV stores the colors in BGR sequence and not in RGB
sequence.
Before we write any code, let’s make sure we always use our virtualenv, in the ~/cv
directory, that we already set up with PyCharm.
Launch your PyCharm IDE and make a project (I named my project cviz, short
for “computer vision”). Refer to Figure 2-4 and ensure that you have selected Existing
Interpreter and have our virtualenv Python 3.6(cv) selected.

14
Chapter 2 Core Concepts of Image and Video Processing

Figure 2-4. PyCharm IDE, showing the setup of the project with virtualenv

Program: Loading, Exploring, and Showing an Image


Listing 2-1 shows the Python code to load, explore, and display an image.

Listing 2-1. Python Code to Load, Explore, and Display an Image

Filename: Listing_2_1.py
1    from __future__ import print_function
2    import cv2
3
4    # image path
5    image_path = "images/marsrover.png"
6    # Read or load image from its path
7    image = cv2.imread(image_path)
8    # image is a NumPy array
9    print("Dimensions of the image: ", image.ndim)
10   print("Image height: ", format(image.shape[0]))
11   print("Image width: ", format(image.shape[1]))
12   print("Image channels: ", format(image.shape[2]))

15
Chapter 2 Core Concepts of Image and Video Processing

13   print("Size of the image array: ", image.size)


14   # Display the image and wait until a key is pressed
15   cv2.imshow("My Image", image)
16   cv2.waitKey(0)

The code in Listing 2-1 is explained here.


In lines 1 and 2, we import Python’s print_function from the __future__ package
and cv2 of OpenCV.
Line 5 is simply the path of the image that we are going to load from a directory.
If your input path is in a different directory, you should give either the full or relative
path to the image file.
In line 7, using the cv2.imread() function of OpenCV, we are reading the image into
a NumPy array and assigning to a variable called image (this variable can be anything
you like).
In lines 9 through 13, using NumPy features, we are displaying the dimension of
the image array, height, width, number of channels, and size of the array (which is the
number of pixels).
Line 15 displays the image as is using OpenCV’s imshow() function.
In line 16, the waitKey() function allows the program not to terminate immediately
and wait for the user to press any key. When you see the image window that will display
in line 15, press any key to terminate the program, else the program will block.
Figure 2-5 shows the output of Listing 2-1.

Dimension of the image: 3


Image height: 400
Image width: 640
Image channels: 3
Size of the image array: 768000

Figure 2-5. Output and image display

16
Chapter 2 Core Concepts of Image and Video Processing

The image NumPy array consists of three dimensions: height × width × channel. The
first element of the array is the height, which tells us how many rows our pixel grid has.
Similarly, the second element is the width, which represents the number of columns of
the grid. The three channels represent the BGR (not RBG) color components. The size
of the array is 400×640×3 = 768,000. This actually means that our image has 400×640 =
256,000 pixels, and each pixel has three color values.

Program: OpenCV Code to Access and Manipulate Pixels


In the next program, we will see how to access and modify pixel values using the
coordinate system that we learned about earlier. Listing 2-2 shows the code example
with the line-by-line explanation after it.

Listing 2-2. Code Example to Access and Manipulate Image Pixels


Filename: Listing_2_2.py
1    from __future__ import print_function
2    import cv2
3
4    # image path
5    image_path = "images/marsrover.png"
6    # Read or load image from its path
7    image = cv2.imread(image_path)
8
9    # Access pixel at (0,0) location
10   (b, g, r) = image[0, 0]
11   print("Blue, Green and Red values at (0,0): ", format((b, g, r)))
12
13   # Manipulate pixels and show modified image
14   image[0:100, 0:100] = (255, 255, 0)
15   cv2.imshow("Modified Image", image)
16   cv2.waitKey(0)

Listing 2-2 is explained here.


Lines 1 through 7 import and read the image from a directory path (as explained
when discussing Listing 2-1).
In line 10, we are getting the BGR (and not RBG) values of the pixel at coordinates
(0,0) and assigning them to the (b,g,r) tuple using the NumPy syntax.

17
Chapter 2 Core Concepts of Image and Video Processing

Line 11 displays the BGR values.


In line 14, we are taking a range of pixels from 0 to 100 along the y-axis and from 0
to 100 along the x-axis to form a 100×100 square and assigning the values (255,255,0) or
pure blue, pure green, and no red to all the pixels within this square.
Line 16 displays the modified image.
Line 17 waits for the user to press any key for the program to exit.
Figure 2-6 shows some sample output of Listing 2-2.

Blue, Green and Red values at (0,0): (40, 55, 134)

Figure 2-6. Output and modified image display

As shown in Figure 2-6, the modified image has a 100×100-pixel square at the top-left
corner in aqua, represented by (255,255,0) of the BGR scheme.

D
 rawing
OpenCV provides convenient methods to draw shapes on an image. We will learn how to
draw a line, rectangle, and circle on an image using the following methods:

Line: cv2.line()
Rectangle: cv2.rectangle()

Circle: cv2.circle()

Drawing a Line on an Image


We will use a simple method of drawing a line on an image, shown here:

1. Load the image into a NumPy array.

2. Decide the coordinates of the starting position of the line.


18
Chapter 2 Core Concepts of Image and Video Processing

3. Decide the coordinates of the end position of the line.

4. Set the color of the line.

5. Optionally, set the thickness of the line.

Listing 2-3 demonstrates how to draw a line on an image.

Listing 2-3. Drawing a Line on an Image

Filename: Listing_2_3.py
1    from __future__ import print_function
2    import cv2
3
4    # image path
5    image_path = "images/marsrover.png"
6    # Read or load image from its path
7    image = cv2.imread(image_path)
8
9    # set start and end coordinates
10   start = (0, 0)
11   end = (image.shape[1], image.shape[0])
12   # set the color in BGR
13   color = (255,0,0)
14   # set thickness in pixel
15   thickness = 4
16   cv2.line(image, start, end, color, thickness)
17
18   #display the modified image
19   cv2.imshow("Modified Image", image)
20   cv2.waitKey(0)

Here is the line-by-line explanation of the code.


Lines 1 and 2 are the usual imports. From now on, I will not repeat the imports
unless we have a new one to mention.
Line 5 is the image path.
Line 7 actually loads the image into a NumPy array called image.
Line 10 defines the starting coordinates of the point from where the line will be
drawn. Recall that the location (0,0) is the top-left corner of the image.
19
Chapter 2 Core Concepts of Image and Video Processing

Line 11 specifies the coordinates of the endpoint of the image. You will notice that
the expression (image.shape[1], image.shape[0]) represents the coordinates of the
bottom-right corner of the image.
You have probably guessed by now that we are drawing a diagonal line.
Line 13 sets the color of the line we are going to draw, and line 15 sets its thickness.
The actual line is drawn in line 16. The cv2.line() function takes the following
arguments:

–– Image NumPy. This is the image where we are drawing the line.
–– Start coordinates.

–– End coordinates.

–– Color.

–– Thickness. (This is optional. If you do not pass this argument, our


line will have a default thickness of 1.)

Finally, the modified image is shown on line 19. Line 20 waits for the user to press
any key to terminate the program. Figure 2-7 shows the sample output of the image we
just drew a line on.

Figure 2-7. Image with a diagonal line in blue

20
Chapter 2 Core Concepts of Image and Video Processing

Drawing a Rectangle on an Image


Drawing a rectangle is easy with OpenCV. Let’s dive into the code directly (Listing 2-4).
We will first load an image and draw a rectangle to it. We will save the modified image to
the disk.

Listing 2-4. Loading an Image, Drawing a Rectangle to It, Saving It, and
Displaying the Modified Image
Filename: Listing_2_4.py
1    from __future__ import print_function
2    import cv2
3
4    # image path
5    image_path = "images/marsrover.png"
6    # Read or load image from its path
7    image = cv2.imread(image_path)
8    # set the start and end coordinates
9    # of the top-left and bottom-right corners of the rectangle
10   start = (100,70)
11   end = (350,380)
12   # Set the color and thickness of the outline
13   color = (0,255,0)
14   thickness = 5
15   # Draw the rectangle
16   cv2.rectangle(image, start, end, color, thickness)
17   # Save the modified image with the rectangle drawn to it.
18   cv2.imwrite("rectangle.jpg", image)
19   # Display the modified image
20   cv2.imshow("Rectangle", image)
21   cv2.waitKey(0)

Here is a line-by-line explanation of Listing 2-4.


Lines 1 and 2 are our usual imports.
Line 5 assigns the image path.
Line 6 reads the image from its path.

21
Another Random Document on
Scribd Without Any Related Topics
prays, in its quaint Norman French that "les fees de Gardien de Flete
sorént mys en certain" that the fees might be settled.
It is possible that extra fees were taken for a certain amount of
liberty allowed to the prisoners by the Warden, who would allow him
to go out of gaol on certain conditions, and we may be certain, for a
consideration also. The Warden was answerable for his Prisoner, and
if he escaped, he had to pay the debt, so that we may be certain
that his ephemeral liberty was highly purchased. That this was the
case we find in 7 and 8 Hen. IV. (1406)[94] "que si ascun Gaoler
lesseroit tiel Prisoner aler a large par mainprise [95] ou en baile, que
adonques le persone envers qi le dit Prisoner estoit condempne
aureoit sa action et recoverir envers le dit Gaoler." Or in English,
"That if any Gaoler allowed such Prisoner to go at large, either by
mainprize or bail, that, then, the Person to whom the Prisoner was
indebted might have his action, and recover against the said Gaoler."
Yet, notwithstanding this, there were many actions brought against
the Wardens for allowing their prisoners to escape. A relic of this
power of the Wardens to accord a certain amount of liberty to their
prisoners, obtained till the last hours of the Fleet. There was, in the
Rules, a defined district surrounding the Prison, in which prisoners,
on providing approved sureties for the amount of their debt, and
paying some fee, might reside, on condition that they did not
overstep the boundaries. That this custom of granting temporary
exeats was very ancient, is indisputable, for, in the 1 Richard II.
(1377) a complaint was made that the Warden of the Fleet
"sometimes by mainprize, or by bail, and sometimes without any
mainprize, with a Baston of the Fleet," i.e., accompanied by a prison
official, would allow his charges to go abroad, "even into the
country."
It is impossible to give a list of all the prisoners of note who were
committed to the Fleet, and they must only be glanced at, but with
the accession of Mary, some illustrious and historical names appear.
First, and foremost, and almost immediately after her accession to
the throne, we read, thanks to the preservation and collation, of
State Papers,[96] that on the 29th of July, 1553, a letter from the
Privy Council was sent to the "Wardene of the Flete, for the
apprehensyone and commyttyng of the Lord Russell, Anthonye
Browne of Essex, and John Lucas." All these prisoners seem to have
been treated with great leniency, for there is a letter (July 31) to the
Warden of the Fleet bidding him to give Mr. Lucas and Mr. Cooke the
libertye of his Garden, so that there must have been a garden then
attached to the Fleet prison—and a postscript orders that "he shall
delyuer Mr. Anthonye Browne, and suffer hym to goo to his awne
Howse."
Nor were the others kept long in durance, for on the 3rd of Aug.,
1553, the Council wrote to the Warden willing him "To set at libertye
John Lucas, and John Cocke, Esquiers, giueing them
Commaundement withall to repaire to their Mancion Howses and
their to make theire aboode vntill they shall here further of the
Queene's Pleasure." And even the incarceration of Lord Russell was
mollified, for a letter was written on 9th Aug. to Mr. Garret, one of
the Sheriffs of London, "whereby the Countesse of Bedforde is
licensed to have free access twise or thrise in the week, unto the
Lord Russell, her son, remayning in the said sheriff's custodie, so the
sheriff be present at their Talke and Conference."
I give the above so as not to spoil the continuity of the story, but
there is mention of the Fleet prison long before; for instance, in
1355, Edward III. wrote "to his well-beloved and trusty, Simon
Fraunceys Mayor of the City of London, Hugh de Appleby, and
Robert de Charwaltone, greeting. Whereas we have been given to
understand that the Foss [97] by which the mansion of our Prison of
Flete is surrounded, and which, for safety of the said prison was
lately made, is now obstructed and choked up by filth from latrines
built thereon, and divers others refuse thrown therein, that there is
cause to fear for the abiding there of the persons therein detained,
by reason of the same; and because that, by reason of the infection
of the air, and the abominable stench which there prevails, many of
those there imprisoned are often affected with various diseases and
grievous maladies, not without serious peril unto themselves. We,
wishing a befitting remedy to be applied thereto, and that the said
Foss may be restored to its former state, in which it was when it was
first made, and so improved; and, for making provision thereon,
desiring upon the matters aforesaid more fully to be informed, have
assigned you, and any two of you, to survey the Foss aforesaid, &c."
This warrant was followed by an Inquest held at the Church of St.
Brigid in Fleet Street on Tuesday, the 9th of January, 1356, on the
oath of Richard le Cok, (Cook) Nicholas le Sporière (Spurrier), and
Thomas le Glaswrighte (Glassblower) and nine others. From it we
learn that the "Foss of Flete" ought to be ten feet in breadth all
round the Prison; that it ought to be so full of water that a boat
laden with one tun of wine might easily float round it; and that the
shelving banks of the Foss were then covered with trees. Also that it
was quite choked up with the filth of laystalls and sewers
discharging into it; and that no less than eleven necessary houses
(or wardrobes, as they seem very generally to have been called in
the thirteenth and fourteenth centuries) had been illegally built over
it "to the corruption of the Water in the Foss aforesaid; and to such
an extent is the flow of water obstructed and impeded thereby, that
the said Foss can no longer surround the Prison with its waters, as it
should do." [98]
The Acts of the Privy Council throw some light on the Fleet, giving
several instances of Committals thereto, one of the first being 9 Hen.
V. Oct. 14, 1421. [99] Wherein Hugo Annesley, who probably was
then Warden of the Fleet, was directed to incarcerate therein one
Grey de Codenore, who had been exiled, and having received his
passport, remained in England, notwithstanding.
In 1 Henry VI.,[100] 19 May, 1423, the "gardein de notre prisone de
Flete" was commanded to bring before the King some prisoners
whom he had in custody, namely Huguelyn de Chalons, Johan Billy,
Johan de Cheviers, Regnault de Graincourt, Hellyn de Bassiers,
Pierre de Mombreham, and Pierre de Pauniers "noz prisoniers prisez
a la reddicion de notre ville de Harefleu."
In the fifteenth and sixteenth centuries are many notices of
committals to the Fleet, so numerous that I can only mention a few,
one only of which I give in the original spelling. 32 Hen. VIII. Sept.
9, 1540.
"Lr̃es was also brought from the Lord Pivey Seale, declaring a
certayn affray to be made by Sr Geoffrey Poole in Hampshyre upon
one Mr. Gunter a justice of peax, for that (as Poole sayd) one of
Gunter's srvants had spoken evill of hym, and for that also that
hymself Gunter had disclosed to the King's Counsail in the tyme of
Poole's trouble certain secret conference which Poole had wt hym.
And answer was made to the sayd Lord Pivy Seale that calling the
complaynt eftesones before hym the lordes and others the gent̃ and
justices of peax in the cūtrey to thentent the cryme of Sr Geffrey
might be notorious to all the Cūtrey there he should c̃mytt the said
Sr Geffrey to the Flette to remayne there until further knowledge of
the Kings pleasr."
Evidently great interest was made for this naughty Sir Geoffrey, for
we learn on Sept. 24th that "It was declared to the Lady Poole, the
wife of Sir Geoffrey Poole, that the King's higness had pardoned her
husband of his imprisonment," and the Lord Privy Seal was directed
to release him. But he seems to have been a very cantankerous
knight, for we find him in hot water again next year. April 8, 1541,
"Whereas Sir Geoffrey Poole, Knight, had violently and contrary to
the King's Highness' peace assaulted and hurt [101] Sir John Mychaill
clerk, parson of Racton in the County of Sussex," and he had to put
in sureties to keep the peace towards the said parson, and to
answer the bill preferred against him. But it seems that he had some
provocation, for a letter was written to him requiring him to
remember, as far as he could, the "haynous and traytorous woords
spoken by Sr John Michaell."
On Nov. 7, 1540, Browne, the son and heir of Sir Matthew Browne of
Surrey, was committed to the Fleet, together with some of his
servants, for burning a certain stack of wood in Surrey. On Jan. 8,
1541, John Gough of London, printer, was sent to the Fleet for
printing and selling a seditious book. On March 18, 1541, there
seems to have been a riot among some of the servants of the
Gentlemen of the Privy Chamber, and three of them were committed
to the Fleet. On April 24, 1541, a smuggler was put into ward here,
one Giles Hasebarde of Southampton, a "berebruer," who had put on
board "a ship of Holland, named the Mary of Dordroyt," five pockets
of wool, without a licence, intending to send them to Flanders. For
this he was sent to the Fleet, the wool confiscated to the King's use,
and the Master of the ship was mulcted in half the value of his
vessel; but Hasebarde was not long in durance, as he was liberated
on April 30th. To thoroughly understand the reason of this man's
imprisonment in the Fleet, we must remember that he was sent
there as being a Debtor to the King, and in the fifteenth century it
was a very common practice for delinquents who were confined in
other London prisons to confess themselves, by a legal fiction,
debtors to the King, in order to get into the Fleet prison, which was
more comfortable. But to show the variety of so-called crimes, or
misdemeanours, which were punishable by imprisonment here, there
is the case of John Barkley of Canterbury, innholder, who was
committed to the Fleet for having molested the King's Highness with
sundry troublous supplications, and it was found that he "appered
manyfestly to be a cōmen barrater [102] and a malicious pōmoter of
false and injust mattiers to the gret vexac̃on of the Kings faithfull
subjects."
It was also used as a house of detention, for we find Oct. 17, 1541,
that Cowley the Master of the Rolls in Ireland, was examined, but
because the time was too short to do it thoroughly, the Lord
Chancellor sent him to the Fleet "untill syche tyme as the King
sholde com̃ to London." It seems to have been a refuge for
misdemeanants, for April 3, 1542, John Bulmer Esquire, for his wilful
disobeying of an order taken between him and his wife by the
Council, was committed to the Fleet. And does not Shakespeare
make Sir John Falstaff a denizen of this prison? (Second Part King
Henry the Fourth, last scene).
"Chief Justice. Go, carry Sir Iohn Falstaffe to the Fleete
Take all his Company along with him.

Falstaffe. My Lord, my Lord.

Chief Justice. I cannot now speake, I will heare you soone:


Take them away."

Sir Rd. Empson, so well known in Henry the Seventh's time, was
indicted for sending, without process, persons accused of murder,
and other crimes, "to the late King's Prisons, to wit the Fleet, the
Compter, and the Tower of London." And, from the Articles of
Impeachment against Cardinal Wolsey, it would seem that he was in
the habit of committing to the Fleet, those who thwarted him in his
demands. One case (Article 38) is: "Also that the said Lord Cardinal
did call before him Sir John Stanley Knt which had taken a Farm by
Cōvent Seal of the Abbot and Cōvent of Chester, and afterwds by his
Power and Might, contrary to Right, committed the said Sir John
Stanley to the Prison of the Fleet by the space of a Year, unto such
time as he compelled the said Sir John to release his Cōvent Seal to
one Leghe of Adlington, which married one Lark's daughter, which
woman the said Lord Cardinal kept, and had with her two Children;
whereupon the said Sir John made himself Monk in Westminster, and
there died."
Here is another example of the Cardinal's highhanded method of
dealing with those who did not exactly bend to his will, in Article 41
of his Impeachment: "Also where one Sir Edward Jones, Clerk,
parson of Orewly in the County of Bucks, in the 18th year of your
most noble reign, let his sd parsonage with all tithes and other
profits of the same to one William Johnson, for certain years; within
which years, the Dean of the s'd Cardinal's College in [103] Oxenford
pretended title to a certain portion of Tithes within the sd parsonage,
supposing the sd portion to belong to the parsonage of Chichley,
which was appointed to the Priory of Tykeford, lately suppressed,
where (of truth) the Parsons of Orewly have been peaceably
possessed of the s'd portion out of the time of mind: Where upon a
Subpœna was directed to the said Johnson to appear before the
Lord Cardinal at Hampton Court, out of any term, with an injunction
to suffer the said Dean to occupy the said portion. Whereupon the
said Johnson appeared before the said Lord Cardinal at Hampton
Court, where without any Bill the said Lord Cardinal committed him
to the Fleet, where he remained by the space of twelve weeks,
because he would not depart with the said Portion: and at last, upon
a Recognizance made, that he should appear before the said Lord
Cardinal, whensoever he was commanded, he was delivered out of
the Fleet. Howbeit, as yet, the said Portion is so kept from him that
he dare not deal with it."

Footnotes
[84] Mag. Rot. 9 Ric. I. Rot. 2a, Lond. & Midd.
[85] Mag. Rot. 9 Ric. I. Rot. 14b, Kent.
[86] Liberate Rolls, p. 25. Rot. Lit. Pat. Hardy, p. 4.
[87] Rot. Cancell. 3 John, f. 100.
[88] Close Rolls, 6 John, f. 33.
[89] Close Rolls, 2 Hen. III., f. 346.
[90] Mag. Rot. 1 Ric. I. Rot. 2b, Bedef. Til de Oblatis Curiæ.
[91] Mag. Rot. 5 Ric. I. Rot. 2a, Nordfolch and Sudfolch.
[92] See Platt's Case cited Vaughan's Reports 1677, p. 243.
[93] Rolls of Parl. vol. iii. p. 469.
[94] Ibid. vol iii. p. 593a.
[95] Allowing a prisoner to go at liberty on finding sureties.
[96] Hayne's State Papers, vol. i.
[97] The moat or ditch fed by the Fleet, which washed the
walls of the prison.
[98] See "Memorials of London and London Life in the
Thirteenth, Fourteenth, and Fifteenth Centuries," by H. T.
Riley, 1847, pp. 279, 280.
[99] "Proceedings and Ordinances of the Privy Council of
England," edited by Sir H. Nicholas, 1834, vol. ii. p. 303.
[100] Ibid. vol. iii. p. 93.
[101] Beneficed Clergy were given the title of Dominus or Sir
—as Sir Hugh Evans, in the Merry Wives of Windsor.
[102] A vexatious and litigious person—one who stirs up
strife.
[103] Christ Church, Oxford.
CHAPTER XX.

T
HE Fleet was, evidently, a handy prison, elastic enough to suit all
cases, for on Aug. 19, 1553, at the Star Chamber, "Roger Erthe,
alias Kinge, servaunt to Therle of Pembroke, and William Ferror,
servaunt to the Lord Sturton, were, for making of a Fraye,
committed to the Charge of Warden of the Fleete."
In September, 1553, the Fleet received a prisoner whose name is
historical wherever the English language is read, for the Privy
Council being held at Richmond, on the 1st of Sept. "This day
appered before the Lordes, John Hooper, Bishop of Gloucester, and
Miles Coverdale, Bishop of Exon. And the said Hooper, for
Considerations the Councell moving, was sent to the Fleete."
Turning from Mary's reign to that of Elizabeth, we find equal
religious intolerance, for we read in Strype's "Annals of the
Reformation, A.D. 1582, "that Fleetwood, the Recorder of London,
sent a letter to the Lord Treasurer, informing him that one Osborn, a
priest and Franciscan friar, had been examined, and confessed that
"in crastino Epiphaniæ, he said Mass in the Fleet (where many
recusants were committed) in the Lord Vaux's Chamber, (to whom
he was related) before that Lord, Mr. Tresham, Mr. Tyrwhit, and
others," which three, at the London Sessions, in Guildhall, were
convicted on Osborn's evidence.
Fleet parsons were evidently an institution in the sixteenth century,
for besides the above-mentioned Osborn, there was another
committed to the Fleet, on May 27, 1584, one Sir R. Stapleton. His
fault seems to have been that he had preached against the
Archbishop of York, for which he was arraigned in the Star Chamber,
and was, with others, ordered to read an apology—which he did—
but in such a contemptuous manner, that he was sent to the Fleet.
In the seventeenth century, many Puritans were incarcerated here,
especially after the Restoration, when their gloomy fanaticism ill
accorded with the ideas of the age. The bow had been strung too
tightly during the Commonwealth, and when it was unstrung the
reaction was great. So many were put into prison for conscience'
sake. Even in Elizabeth's reign there were many in prison, and we
can hardly wonder at it when we consider it was an age of religious
intolerance, and the religion professed by these devotees was of a
most unattractive character. Strype, writing of A.D. 1588, says of
them:

"In the Summer Time they meet together in the Fields, a Mile or
more.[104] There they sit down upon a Bank. And divers of them
expound out of the Bible, so long as they are there assembled.
"In the Winter Time they assemble themselves by five of the
Clock in the Morning to the House where they make their
Conventicle for the Sabbath Day, Men and Women together.
There they continue in their kind of Prayers, and Exposition of
Scriptures, all the Day. They Dine together. After Dinner make
Collections to pay for their Diet. And what money is left, some
of them carryeth to the Prisons, where any of their sort be
committed.
"In their prayers, one speaketh, and the rest do groan and sob,
and sithe,[105] as if they could wring out Tears. But say not after
him that prayeth. Their Prayer is Extemporal."

In January, 1600, Lord Grey of Wilton was committed to the Fleet,


by Queen Elizabeth's order, for assaulting the Earl of Southampton,
on horseback, in the public street.
There is a fair bibliography of the Fleet prison in the seventeenth
century. In 1620-1 there was a broadsheet published "A briefe
collection of the exactions, extortions, oppressions, tyrannies, and
excesses towards the liues, bodies and goods of prisoners, done by
Alexander Harris, Warden of the Fleete, in his foure yeares
misgouernment, ready to be proued by oath and other testimonies."
This was answered by Harris, and his MS., which is in the possession
of the Duke of Westminster, was published by the Camden Society in
1879, entitled the "Œconomy of the Fleete; or an Apologeticall
Answeare of Alexander Harris (late Warden there) unto XIX Articles
set forth against him by the prisoners." Of which book more anon.
Then there was a "Petition to Parliament of the distressed prisoners
in the King's Bench, Fleet and other prisons"—but this has no date.
In 1647 was published "A Whip for the Marshal's Court by Robert
Robins Gent, being his Petition to the House of Commons." The
preface to the Reader, is dated from the Author's "Iron Cage in the
Fleet." In 1653 there was "A Schedule; or, List of the Prisoners in the
Fleet remaining in custody May 25, 1653."Some of them were very
bad cases, as "William Gregory committed February 7, 1651, one
Outlawry after Judgment, severall other Outlawries and Trespasses,
no sums mentioned;" or "Hustwayte Wright committed June 29,
1650, for £31 1s., Execution, besides Outlawries, Latitats and Cap.
no sum appearing."
"Thomas Keneston committed Nov. 4, 1646, for 51,000 Actions, and
severall Orders of the Exchequer." In 1669 appeared "A Companion
for Debtors and Prisoners, and advice to Creditors, with a description
of Newgate, the Marshalsea, the two Counties, Ludgate, the Fleet,
and King's Bench prison." In 1671 was published "A Short Narrative,
or Anatomie of the Fleet Prison &c.," by John Knap, M.D. In 1690
there was "A plea for the City Orphans and Prisoners for Debt." In
1691 appeared a soul-harrowing little book, called "The Cry of the
Oppressed, a tragicall Account of the unparalleled Sufferings of the
poor imprisoned Debtors and Tyranny of their Gaolers, with the case
of the Publisher (Moses Pitt)." Here the interest is much heightened
by numerous engravings showing how prisoners were beaten, made
to feed with hogs, were covered with boils and blains, the females
outraged by their gaolers, and many other enormities. I would fain
quote at length from this book, but space will not admit of it. In
1699 we find "An Argument that it is impossible for the nation to be
rid of the grievances occasioned by the Marshal of the King's Bench
and Warden of the Fleet, without an utter extirpation of their present
Offices."
The Case as made out by the prisoners against the Warden,
Alexander Harris, in 1620-1, was, if it could have been thoroughly
substantiated, most damaging to him, but they overreached
themselves by their manifest exaggeration. A few examples will
suffice. There were nineteen counts against him all of grievous
weight, but we will only take four as a fair sample. (1) Murder; (2)
Felony; (3) Robbery; (4) Excessive Rates for Chambers. First, as to
the Charge of Murder, this is the accusation: "After knowne quarrels
and fightings between two prisoners, lodging them in one chamber,
where, quarrelling and fighting againe, and notice to him thereof
giuen, and of likely further mischiefe; this notwithstanding,
continuance of them together, vntil the one murthered the other."
This referred to two prisoners, Sir John Whitbrooke and another
named Boughton. According to the Warden's account Whitbrooke did
not deserve much pity. In July, 1618, he was given into the Warden's
Custody, by the order of two Courts, to be kept a close prisoner, but
he soon developed "dangerous energy," for on the 10th of the same
month, almost immediately after his committal, he "came into the
Warden's studdy where the Warden (in his gowne) was wryteing,
and fashioned his speech, sayeing that he came to speake with the
Warden about his lodging, who answeared that he would willingly
speake about that, and money for it, whereupon the Warden putting
dust[106] upon the wryteings and turneing his back to lay them
aside, Sir John Whitbrooke strooke him on the head with the sharpe
ende of a hammer, whereof one Cleft was before broken off, and the
other cleft newly whett, giveing fower wounds to the scull, and some
bruses before the Warden could close with him; but then the
Warden thrusting him out of the studdy, did throwe Whitbrooke on
the back, and took away the hammer, Whitbrooke (being
undermost) did hould the forepart of the Warden's gowne soe as he
could not rise; att which tyme the Warden's blood abundantly
gushed downe upon Whitbrooke, and the Warden could have beaten
out Whitbrooke's braynes with the hammer, but that he was neither
wrothfull nor daunted.
"Then after, two maydes servants (heareing the noyse) came into
the roome, and one loosed Whitbrooke's hands from the Warden's
gowne, or ells the Warden must have killed him to acquitt himselfe.
Soe soone as the maydes came the Warden shewed them the
hammer all bloody, telling them that Whitbrooke had wounded him
therewith; the butler of the howse then alsoe comeing upp to cover
the table, the Warden bidd him and others (which followed) to laye
hands upon Whitbrooke &c.; but to take heed they hurt him not; soe
they letting him rise and rest himselfe, he took a stiletto out of his
pockett and stabbed the Warden's deputie cleane through the
middle of his hand, which (notwithstanding it was presently dressed
by a good chirurgion) did rankle upp to his shoulder, and was like to
have killed him; he also stabbed the porter of the howse directly
against the heart, and drewe blood, but it pierced not: he stabbed
the gaoler into the hand and twice through the sleeve of his dublett,
so as then they lay violent hands upon him, put on irons and carryed
him to the strongest warde of the prison (called Bolton's warde)."
And a perfectly proper punishment for any one who ran amuk like
Whitbrooke because there was an organized mutiny. "And upon this
some three score prisoners breake upp all the strongest prisons and
dores of the wards and Tower chamber, assaulting the Warden and
his servants with weapons &c., according to a plott and purpose
before resolved upon, as appeares by depositions."
The poor Warden had no bed of roses, more especially as the female
element was afterwards introduced in the shape of Lady Whitbrooke,
who of course, was a warm partisan of her husband. Harris writes:
"The lady alledgeth that in September the quarrell betweene the
Warden and Whitbrooke was renewed.
"The Warden answeareth that in July, 1619, Whitbrooke and
Boughton with six others (being lodged in a great Chamber)
they and six more shutt out thirtie of their Companie and
fortefied the gaole against the Warden, refused all perswasions
of the Warden, constables, and Alderman's Deputie, the
comands of the Lord Cheife Justice, of the Lord Chauncellor and
his Serjeant at Armes; yet yeilded to the clarke of the councell
sent from the Lords. Whitbrooke and Boughton being then in
one humour; and, upon unblocking the prison, Whitbrooke
desired liberty; it was offred him upon security, he would give
none, then he made question where to lye, to which was
answeared there were five other roomes he might make his
election of, which he would; but he said he would none other
but where he formerly laye (it being indeed the fayrest). They
fortified these roomes againe when the Warden was out of
towne, soe as during Whitbrooke's life and Boughton's being
there with their adherents the Warden had noe comand in that
part of the prison."

It is almost needless to say that these peculiarly unquiet spirits


quarrelled among themselves. We have heard enough of Whitbrooke
to know that he was a quarrelsome cur—impatient of restraint, and
thoroughly lawless in his habits; but it is evident that he persuaded
his wife that he was an injured innocent; for, in poor Harris's
"Apologia pro sua vita," a story which he tells so naively, and so
nicely, he says:
"The lady alledgeth that the Warden (for revenge) resolved and
reported he would send Whitbrooke to Boulton to keepe.
"The Warden answeareth that he for governement sake and to
suppresse misdemeanours doth thretten to putt prisoners
(offending) into Boulton's Wards (Many yeares familiarlie soe called
as he thinketh of bolts or irons put on them), where Whitbrooke was
put when he wounded the Warden and his servants; he continued
there but a small tyme, and was removed to a roome called the
Tower Chamber (where Henry Boughton and many others did lye),
thence Boughton was removed into the common prison in December,
1618, and Whitbrooke was removed thither June 16, 1619, soe as to
that tyme they lay five moneths within one lodging, and six moneths
severed in other lodgings and noe quarrell stirred.
"The Lady alledgeth that presently at their comeing together
Boughton suddenly stabbed and wounded Whitbrooke, whereof he
dyed.
"The Warden answeareth that over and above the eleaven months
aforesaid, yet from June 16th untill September 16, 1619, being 3
moneths, they two combyned in their exploits against the Warden
without falling out (for ought the Warden knewe), but 16 September
Boughton fell out with Harvey (one of his chamber felowes), whom
Boughton assayled with his teeth, and bitt him by the thombe,
whereof Whitbrooke, Willis, Harvey, and others there lodged,
advised the Warden, wishing him to take some course. The Warden
sent divers messages by the gaoler to Whitbrooke to remove thence
and to lye elsewhere; he would not, sayeing none should remove
him but by violence, and they were so strong there, as the Warden
could doe nothing, none ells durst come amongst them. Holmes and
Maunsell offered him libertie amongst other gentlemen upon bonds.
"The Warden acquainted the Lord Chauncellor of their fortifications,
of some other stabbing there, of this particular brawle, and besought
his lordshipp to send them to Newgate. The Lord Chauncellor
comanded such motion to be made at the tyme of a seale; it was
moved by Mr. Woomelayson, as appeares by his briefe, then his
lordshipp wished oath to be made of this offence, and called for
presidents [107] to remove them, in which meane tyme Boughton
(being provoked and wounded by Whitbrooke) did stabb him,
whereof he dyed within 13 dayes, and it was about 14 moneths after
he wounded the Warden and stabbed his 3 servants as appeareth by
the generall lodgeings and places where they laye, sometymes
together, and sometymes severed, ensueing to be seene in the end
of this answeare to this Article, and, if the testimony (which was
long after delivered to the Warden, by a prisoner in the Fleete) be
true, then the same Harvey, and one Tymothy Willis and Sir John
Whitbrooke himselfe, did (of sett purpose) whett on Boughton to
anger and quarrell, because they scorned Boughton and meant to
assayle him.
"When Whitbrooke, Boughton, &c., ymured themselves upp in the
wards as aforesaid, a view or survey of the roomes was given the
Lordes of the Councell, and they (were) satisfied.
"After the tyme of the supposed quarrell (which was about
Whitbrooke's and Boughton's fortifieing the house) they contynued
lyeing where they were before, amongst others.
"Wheresoever they had lyen they might quarrell when they mett, as
Whitbrooke many moneths before broke Willis his head with a pott
or candlestick." These two ill-conditioned animals fell to loggerheads,
and Boughton drew upon Whitbrooke, and so wounded him that
eventually he died. And this shows the very lax discipline that then
obtained in the Fleet. Of course, no weapons should have been
allowed, but "It is alsoe alledged that Boughton did provide a sword,
and it was brought him by a woeman from whom the porter of the
Fleet tooke it, and delivered it to the Warden (as he did indeed) and
therefore say their accusers that the Warden knew the same sword
was to kill Whitbrooke.
"The Warden had it about a yeare and a halfe before this accident
(of Whitbrooke's death) happened, and delivered it back againe to
the woeman that brought it, with charge not to bring any thither
whatsoever.
"It was avouched that the sword was Boughton's, and put to
dressing to a Cutler, who sent it home againe, so as Boughton might
have killed Whitbrooke with it before it went to dressing, if he had
intended any such thing. Nay, Boughton had alwayes in his trunck
(as appeared afterwards) a stilletto so keene, so cleane and ready,
as would soone have done such a fact if he had meant it; yea,
swords and other weapons want not in the Fleete, and the Warden
cannot prevent it. This fact was mere accidentall, and not
precogitate as the lawe hath founde it, which acquitted Boughton of
Manslaughter upon his arraignement." Harris, I think, and, most
probably, my readers will agree with me, has made out a very fair
case in his own favour; but I must not deal with the other charges
against him at such length.

Footnotes
[104] Presumably, from the town.
[105] Sigh.
[106] There was no blotting paper in those days, but pounce
was used, which was either powdered resin, gum sandarach,
or copal, or powdered cuttle fish. I believe that pounce may
even now be bought at law stationers. It was dusted on to
the wet ink by means of a pepper caster.
[107] Precedents.
CHAPTER XXI.

T
HE second count brought against him by his mutinous prisoners
was "Remouing a prisoner out of his chamber, hauing 51 lib. 1 s.
hid vnder his bed, which the prisoner required he might go to
his chamber to dispose of, which was denied, and he thrust vp in
another roome close prisoner, vntill the Warden and some of his
seruants rifled his bed of that mony."
Hear the Warden's defence:— "By this is pretended that one Coppin
(who euer did beare the name of a poore fellowe) lost 51 li., with
takeing whereof, if he dare charge any person or persons the Lawe
is and hath beene open for him theis two yeares past. But his
abettors haue putt it here rather to infame, then that they can think
it true, as by the ensueing answeare appeares.
"For Edward Coppin, liued as a poore prisoner in the Fleete for
breach of a decree, and continueing above six yeares, would never
be drawen to pay the Warden one penny for meate, drinke, lodging,
or attendance; but at last he ran away, and was upon the Warden's
pursuite taken againe, but before he ran away, he was sometymes
restrayned of the libertye of the Fleete yards and walks (as is the
custome of all prisons in England); and he lodging in the three
Tower Chambers with sixteene persons, they often thretned their
keeper to stabb him, to take away the keyes of the prison, to bind
him, to hang him; lastly they fortefied that prison, soe that the
Warden could not dispose or order them. And with two malletts and
steele chissells they had cutt the stone workes of the dore, soe as
noe locks or bolts could shutt them; and while they were thus
doeinge Coppin came downe to fetch a mallett, wherewith he was
taken beneath, and presentlie put into another warde aparte from
his fellowes, about three a clock in the afternoone 15 July 1619, not
speakeing of any money."
Master Coppin was one of Boughton's gang, but even that
malfaiseur could not back up his claim, for "A rumour was spredd in
the Fleete that Coppin had lost 50 li. The Warden heareing thereof,
sent for Coppin, and asked him: he said he would say nothing
except Sir Francis Inglefield were present. Then the Warden said,
Nay, Coppin, if you have nothing to say to me, you may depart
againe.
"Then the Warden was informed by Mr. Boughton and Wall, that the
day before it happened that Coppin was removed, they had made
meanes to borrowe some money upon a pawne, and Coppin
professed and swore he had not so much (being fower (4) pounds)
as they demanded. Then the Warden caused Coppin's trunck (being
new and well locked) to be opened in Coppin's presence, and
delivered it to him, in which Trunck within a Bagg put in a Box (as
they said) there was about xxixs; and then was sett on foote this
rumour when Coppin had advised with Mr. Rookwood to doe it.
"About January 1620, Edward Coppin confessed that he never
receaved any money since he came to Prison.
"Mr. Williams saith that he hath heard that Coppin hath confessed
that he lost noe money."
So we may acquit the Warden on this count. Poor Man! he had a
rough lot to deal with, but it is to our advantage that it was so, for
his refutation of the charges brought against him throws a flood of
light on the domestic manners of the time, and of the Fleet prison in
particular.
The third count against the Warden was one of robbery, "11 lib. 6 s.
taken out of the Trunk, and by violence, from the person of a close
prisoner sicke in his bed, by the Warden and his seruants." And
Harris meets this, as all others, fairly and straightforwardly. Says he:
— "This toucheth money taken from one Thraske, then a Jewdaiser,
or halfe Jewe, committed close prisoner by the Lords of the
Councell, from whom, and such like, though in the Gatehouse, King's
Bench, Fleete, &c., it hath beene used to take away and keepe their
money, yet the Warden tooke not his until he abused it very
dangerouslie, and whether this takeing away may be said Robbery,
let the answeare followeing decide.
"And although the complainte be used with a Circumstance, as if the
Prisoner were sick, thereby to make a shewe as if the Warden gaped
at his death and money; that was most untrue for Thraske was in
perfect health."
This prisoner was sent to the Fleet, to be put in the pillory, whipped
and branded, and, besides, to suffer solitary confinement, but he
found means to write letters to the King and the Lord Chancellor,
and the Warden was much blamed for allowing him so to do. But
poor Harris, who must have been plagued almost to death by his
very recalcitrant charges, could not find out whence his prisoner
procured his writing materials, and at last came to the correct
conclusion that he was bribing the gaoler who waited upon him. So,
with some servants, he personally searched Mr. Thraske's apartment
and person, and found his pens, ink, and paper, and also £11 6s. in
money, together with a bag and cord with which he used to receive
supplies from outside, and by means of which he disseminated his
pernicious literature. All of which the Warden very properly
confiscated, but the money was kept, and used for the prisoner's
benefit. "When Thraske had worne out his cloathes and desired
other, the Lord Chauncellor bid the Warden buy for Thraske some
cloathes, which was done accordingly, even soe much as Thraske
desired; the Warden alsoe gave him money to buy wyne for his
comforte at tymes." And, in the long run, the poor Warden declares
that he was about £80 out of pocket by his prisoner.
The last charge we will investigate, is that of "Excessiue rates of
Chambers." (No. 13 on the list of 19) "Whereby orders no man
ought to pay for any Chamber, the Warden allowing bed and
bedding, aboue 2s. 4d. a weeke, he exacteth 8s., 10s., 13s. 4d. and
of some twentie shillings a weeke without bedding." The Warden
replies to this that "the Orders of the Prison are, That noe Parlor
Comoners and Hall Comoners must lye two in a Bedd like Prisoners,
They of the Parlor at ijs. iiijd. the weeke. They of the Hall at xiiijd. If
any such will lye in the Prison then there is noe question of their
payment, nor any more required. But the missery is this that none
there will pay at all, but stand upon it that they should pay nothing,
which is contrary to right, to Custome, and to usage.... Ano 1597.
The Prisoners then Articling against the Warden Sett forth that one
Prisoner paid xxxs. others xxs., xvs., xiis., xs. a weeke for Chamber
without Bedd. The Warden then made his Answeare to the
Comittees that he took xs. a Chamber, and the rest was for more
chambers than one, and in respect of Dyett, though they had none,
but fetched it abroad.
"Soe if Prisoners will have more ease than ordinarie, and a Chamber
or two for themselves and theirs in the Warden's howse, they are by
the orders and Constitutions to Compound with the Warden for it, it
being the Warden's freehould, and demyseable.... To such prisoners
as lye two in a Bedd, the Warden is to find them Bedd, and for Bedd
and Chamber they are to pay. Whether by Bedd is meant all
furniture of Bedding, that is to be doubted, for it was never put in
practise; but as for those which lye in the Warden's freehould by
agreement he is not bound to find them Bedd or Bedding except it
be so conditioned. And such will hardly vouchsafe to lye on the
comon Bedding which passeth from Man to Man; And the Warden
can as hardlie buy a new Bedd for every new prisoner which
cometh, and therefore the lodgings of ease were provided for men
of quality and not for the mean sorte of prisoners, as the accusation
would seeme to inferre; And when Mr. Chamberlayne informed
against the Warden touching Chambers, All the cheife gentlemen in
the Fleete certified under their hands that they held their Chambers
by agreement to have a Chamber alone to each, and were contented
with the rates."
That the Wardenship of the Fleet was an onerous position, may be
inferred from Harris's statement that "he hath had at one tyme the
King's prisoners for two hundred thowsand[108] pounds debt,
besides the affayres of State."
That the office of Warden of the Fleet was of very ancient origin we
have seen in the case of Nathanael de Leveland, and he also proves
that it was heritable, for he, and his family, had held it for 130 years,
and more. And it had a far-reaching jurisdiction, for in the 3 Eliz.[109]
we learn that "Upon an adjournment of the term to Hertford, several
prisoners were committed to the Castle there. This Castle was part
of the Duchy of Lancaster. The Queen had granted a patent to A. of
the Custody of this Castle for his Life; resolved by the Judges that
the Warden of the Fleet shall have the Custody there of the
Prisoners committed by the Chancery, Common Pleas and
Exchequer: For he is the Officer of those Corts; and although the
Patentee has the Custody of the Castle, and though it be the Prison
of the County, yet his interest ought to give place to the public weal,
and common justice."
In course of time, the Wardenship became a position which was
openly sold; and our old friend Harris makes no secret of it. "They
likewise alledge that Io Elizabeth it was purchased by Tirrell at the
rate of 160 li. per annum and that long after it was held at 100 li.
per annum, and refused for 200 li. But now that (thorough extortion)
there is made 4,000 li. per annum by the relation delivered to one
Mr. Shotbolt.
"To which is answeared, that the purchase paid by Tirrell, (as
appears by the deed inrolled) was 6,000 markes or 4,000 li. which, if
it be devided at tenne or twelve yeares purchase, being more than
an office of that nature was worth in those dayes (which is above
three score yeares past) it will bring 400 li. tenne yeares purchase,
and therefore here is sutor ultra crepidam, for 160 li. at that rate
would yeild but 1,600 li. in money, and there was not then the fift
part of the buildings and lodgings which now are.
"Mr. Anslowe (as is credibly informed) held it by fyne (and
otherwise) at 600 li. per annum, and had but some part of the
benefitts of the prison, nothing of the pallace at Westminster. And as
for this Warden's valuation of it at 4000 li. per annum, it might be,
supposeing that if the benefitts of the pallace were had &c. But what
if the one with the other cost in expences 4,000 li. per annum, what
will be then advanced?" &c.
This selling of the Office of Warden, led to a great squabble in the
early days of Queen Anne's reign, and it seems to have arisen in this
way. A Warden of the Fleet, named Ford, in the reign of William and
Mary, was found guilty of suffering one Richard Spencer to escape,
but was acquitted of some minor charges, and a certain Col. Baldwin
Leighton obtained a grant of the Office on April 6, 1690. On June 25,
1691, this grant was quashed, and Leighton soon after died. A Mr.
Tilley, in the fifth year of William and Mary purchased the
Inheritance of the said Office, together with the Mansion and
Gardens thereto appertaining, but on Dec. 23, 1704, judgment was
given in the Queen's Bench that the Office be seized into her
Majesty's hands, and this was affirmed in Parliament.
The discipline in the prison at this time seems to have been very
bad, so much so that many witnesses who could have spoken of
Tilley's misdeeds were hindered from giving evidence, some by
being put into dungeons; others, by violence, bribes, or other
artifices. Take a case in point, which happened about this time. The
case of Robert Elliot and others. "One Francis Chartyres was
Arrested at the several Suits of the said several Persons, about the
4th of May last, all their Debts amounting to 140 l. and upwards,
which cost them 20 l. to effect: And the said Francis Chartyres being
a stubborn and an obstinate Man, and dangerous to Arrest, he
having killed several Persons upon the like attempt, and at this
Arrest run the Bayliffs through. And after he was taken, he by
Habeas Corpus turned himself over to the said Fleet Prison. And Mr.
Tilley, and the Turnkey, and one Whitwood, an Officer of the Fleet,
were acquainted, by the persons above mentioned, what a
dangerous Man he was, and what it cost them to take him; but they
took no notice thereof, and declared they would let him out for all of
them; and so they did, and the next Day the said Persons Arrested
him again, and he went over to the Fleet a second time, and was
immediately set at liberty; who coming to the Persons aforesaid, at
whose Suit he was Arrested, bid them defiance; saying, He was a
Freeman, for that he had given 18 Guineas for it, and they should
never have a farthing of their Debts, which they now doubt of, the
said Chartyres being gone for Scotland."
Hatton, in his "New View of London," 1708, gives, the boundary of
the Rules, and also descants on the pleasantness of the Prison, as
an abode. "Fleet Prison, situate on the East side of the Ditch,
between Ludgate Hill and Fleet Lane, but the Rules extend
Southward on the East side of Fleet Canal to Ludgate Hill, and
thence Eastward to Cock Ally on the South side of Ludgate Hill, and
to the Old Bayly on the North, and thence Northward in the Old
Bayley both sides the Street, to Fleet Lane, and all that Lane, and
from the West End, southward to the Prison again. It is a Prison for
Debtors from any part of the Kingdom, for those that act or speak
any thing in contempt of the Courts of Chancery and Common Pleas;
and for the pleasantness of the Prison and Gardens, and the
aforesaid large extent of its Rules, it is preferred before most other
Prisons, many giving Money to turn themselves over to this from
others."

Footnotes
[108] Equal in our currency to about three times the amount.
[109] Reports of Cases, &c., by Sir James Dyer (ed. 1794)
vol. ii. p. 204 a.
CHAPTER XXII.

T
HINGS got so bad that Parliament ordered a Committee to
inquire into it, and they began their sitting in Feb. 25, 1729. But,
previously, the prisoners had petitioned the Lord Chief Justice
and other justices without effect, and those petitions with Huggins'
(who was the Warden) replies were published in a folio pamphlet,
which contains much information.[110] The first petition was in 1723,
and it was mainly addressed to the extortions of the Master, the
sixth Article alledging that the fees exacted by the Warden were in
excess of those settled by Law, Nov. 14, 1693—instanced as follows:
Warden. Legal.
For liberty of the House
£2 4 4 1 6 8
and Irons at first coming in
Chaplain 0 2 0
Entering every Name and
0 0 4
Cause
Porter's fee 0 1 0 0 1 0
Chamberlain's Fee 0 3 0 0 1 0
The Dismission Fee for
0 12 6 0 7 4
every Action
Turnkey's Dismission 0 2 6
———— ————
£3 5 4 £1 16 4
======= =======
The eleventh prayer of this Petition was, "And lastly, that for the
better suppressing Prophaneness and Immorality among us, and
that the Misery of Imprisonment may in some measure be alleviated
by the Observance of good Manners, Cleanliness, and Quietude, we
humbly pray your Lordships would enable us to regulate our selves
in such Manner as the Prisoners in the King's Bench are empowered
to do by a Rule of that Court, 20 die post festim Sanctæ Trinitatis.
11 Anne."
Huggins replied to all the petition, but his answer to No. 6 was "The
Warden saith, That so soon as the Fees were settled by this
Honourable Court, he caused a Copy thereof to be framed and hung
up in the Common Hall of the House, signed by Sir George Cook;
also a Copy of the Rules and Orders of the House, which said copies
the Prisoners were pleased to burn, tear to Pieces, and obliterate;
and the Warden denies that he has taken or receiv'd, or any for him,
to his knowledge, more, or greater, Fees than were contained in the
said Copy of Fees hung up in the said Prison."
And as to the Eleventh prayer of the Petitioners "The Warden saith,
that the Prisoners in general, are so very ungovernable, that they
have tore up the Trees around the Bowling Green, and cut down
several of the Trees in the back part of the Prison, set by the Warden
some years since, for the better Accommodation of the Prisoners;
also broke down the Stocks in the said Prison, and the Houses of
Easement were fitted up lately by the Warden, they have torn it
almost to Pieces, and committed other Outrages, and most of them,
altho' two Years in Arrears of Rent to the Warden, refuse to pay him
any Part thereof, and will by Force, and in defiance of the Warden
and his Officers, keep in Possession of the Rooms and Furnitures,
Swearing to stand by each other."
Petition after petition was sent from the Prisoners to the Lord Chief
Justice about the oppressions of Huggins and his myrmidons, and
duly answered in some shape by the Warden, but there was one, in
which the fourteenth Charge is as follows. "That the Warden, on the
Death of any Prisoner detains the Body from his Friends and

You might also like