Professional Documents
Culture Documents
Libraries
Libraries
SciPy is a collection of mathematical algorithms and convenience functions built on the NumPy
extension of Python. It adds significant power to the interactive Python session by providing the user
with high-level commands and classes for manipulating and visualizing data. With SciPy, an
interactive Python session becomes a data-processing and system-prototyping environment rivalling
systems, such as MATLAB, IDL, Octave, R-Lab, and SciLab.
The additional benefit of basing SciPy on Python is that this also makes a powerful programming
language available for use in developing sophisticated programs and specialized applications.
Scientific applications using SciPy benefit from the development of additional modules in numerous
niches of the software landscape by developers across the world. Everything from parallel
programming to web and data-base subroutines and classes have been made available to the Python
programmer. All of this power is available in addition to the mathematical libraries in SciPy.
This tutorial will acquaint the first-time user of SciPy with some of its most important features. It
assumes that the user has already installed the SciPy package. Some general Python facility is also
assumed, such as could be acquired by working through the Python distribution’s Tutorial. For
further introductory help the user is directed to the NumPy documentation.
The benefit of using SciPy library in Python while making ML models is that it also makes a strong
programming language available for use in developing less complex programs and applications.
SciPy is organized into sub packages covering different scientific computing domains. These are
summarized in the following table:
SciPy Spatial
The scipy.spatial package can calculate Triangulation, Voronoi Diagram and Convex Hulls of a set
of points,by leveraging the Qhull library. Likewise, it contains KDTree implementations for
nearest-neighbour point queries and utilities for distance computations in various metrics.
Convex Hulls:
In mathematics, the convex hull or convex envelope of a set of points X in Euclidean plan or in
a Euclidean space. It is the smallest convex set that contains X.
For example:
from scipy.spatial import ConvexHull
import matplotlib.pyplot as plt
points = np.random.rand(10, 2)
hull = ConvexHull(points)
plt.plot(points[:,0], points[:,1], 'o')
for simplex in hull.simplices:
plt.plot(points[simplex,0], points[simplex,1], 'k-')
plt.show()
Imutils:
A series of convenience functions to make basic image processing functions such as translation,
rotation, resizing, skeletonization, and displaying Matplotlib images easier with OpenCV
and both Python 2.7 and Python 3.
We apply the cv2.warpAffine function.
For example:
translate the image x=25 pixels to the right and y=75 pixels up
translated = imutils.translate(workspace, 25, -75)
Faceutils:
It is used to extract the facial landmark from the image of the subject. There are a variety of facial
landmark detectors, but all methods essentially try to localize and label the following facial regions:
Mouth
Right eyebrow
Left eyebrow
Right eye
Left eye
Nose
Jaw
This method starts by using:
A training set of labelled facial landmarks on an image. These images are manually labelled,
specifying specific (x, y)-coordinates of regions surrounding each facial structure.
Priors, of more specifically, the probability on distance between pairs of input pixels.
Given this training data, an ensemble of regression trees is trained to estimate the facial landmark
positions directly from the pixel intensities themselves (i.e., no “feature extraction” is taking place).
The end result is a facial landmark detector that can be used to detect facial landmarks in real-
time with high quality predictions.
FACIAL LANDMARKS ON THE SUBJECT FACE
Pygame:
Pygame is a cross-platform set of Python modules designed for writing video games. It
includes computer graphics and sound libraries designed to be used with the
Python programming language.
Pygame uses the Simple DirectMedia Layer (SDL) library, with the intention of
allowing real-time computer game development without the low-level mechanics of the C
programming language and its derivatives. This is based on the assumption that the
most expensive functions inside games can be abstracted from the game logic, making it
possible to use a high-level programming language, such as Python, to structure the game.
Pygame version2 was planned as "pygame reloaded" in 2009, but development and
maintenance of pygame completely stopped until the end of 2016 with version 1.9.1.
Pygame commands
import pygame – This is of course needed to access the PyGame
framework.