& &
Jerry
•
• ”
•
• Founder
•
• MIT	edX/MandarinX
•
• https://www.ap-mic.com
• http://dataology.blogspot.tw
• https://www.linkedin.com/in/jerry2012/
(Jerry)
dsjerry2017@gmail.com 2
3
VM
• vmware-tools-distrib
• sudo ./vmware-install.pl
Jupyter Notebook
• sudo pip3	install	jupyter
• sudo apt-get	install	python3-matplotlib
(Computer	Vision)
•
Make	computers	understand	images	and	video.
-
-
-
U
• Safety
• Health	
• Security	
• Comfort	
• Fun	
• Access	
• …….
• 1960
• 1970
• 1990 C 3
• 2000
• 2030
-OCR
(OCR,	Optical	Character	Recognition)
- Face	detection
- Smile	detection
- Object	recognition
- Vision-based	biometrics
- Login	without	a	password
- Shape	Capture		&	Motion	Capture
- Self-Driving	Cars	
Mobileye
– Vision	systems	currently	in	high-end	BMW,	GM,	Volvo,	Tesla
- Interactive	Games:	Kinect
- Industrial	robots
- Medical	imaging
• Viewpoint	Variations
image credit: J. Koenderink
a
“
• Occlusion
image credit: Magritte, 1957
• Clutter
3D
• Optical	Illusions
OpenCV?
OpenCV
• OpenCV 2000 17
• Intel
• *
•
•
• S
• OpenCV C++
• ' Python,	Java,	Matlab,	C#,	Ruby
• OpenCV
• Windows Mac	OS Linux Android
Python	+	OpenCV
• P OpenCV
• (CV)
• OpenCV
• Python Numpy Scikit-learn
• BSD S
•
• Windows Mac Linux
• ' CUDA GPU
• Python
?
•
Title
RGB
3
•
•
•
3
3
RGB &	HSV
• RGB U RGB	color	model
Red Green Blue
a V
• HSL Hue,	Saturation,	
Lightness HSL
• H
• S
0-100%
• V 0-100%
3
OpenCV stores	color	in	the	BGR	format.
3
RGB 3
3 (RGB)
BGR
• cv2.calcHist(images,	channels,	mask,	histSize,	ranges[,	hist[,	
accumulate]])
• images	:	
• Channels [0] [0],[1],[2]( )
• Mask None
• histSize 3 bins [256]
• Ranges [0,	256]
ravel() array
calcHist
enumerate col
OpenCV
• 3 (Square)
np.zeros array
OpenCV
• (Line)
Cv2.line	( )
OpenCV
• 3 (Rectangle)
OpenCV
• (Circle)
OpenCV
• (Polygon)
Image	Manipulations
(Transformations)
• (Transformations) : (Affine) (Non-Affine)	
• (Affine)
• (Non-Affine)	 Scaling
Rotation
Translation
(Translations)
Tx 311.25
Ty 207.5
Tx
Ty
(Rotations)
Cos θ -Sin θ
Sin	θ Cos	θ
θ	 ”
θ
*X Y
(Rotations)-Transpose
c (Horizontal	Flip)
1 c
0
-1 c
*(Scaling) (Resizing)	 (Interpolations)
* 3/4
cv2.INTER_AREA
* cv2.INTER_CUBIC
resize cv2.INTER_LINEAR
None Fx Fy *
(Image	Pyramids)
(Cropping)
r (Added)	&	 (Subtracted)
Mr
(Bitwise)	&	“ (Masking)
Bitwise	Operations	and	Masking
3
(Convolutions)	& U (Blurring)
(Sharpening)
Thresholding,	Binarization &	Adaptive	Thresholding
127 0 255
127 255 127 0
127 127 255
127 0 127
127 127 0
Thresholding,	Binarization &	Adaptive	Thresholding
127 0 255
U o
Adaptive Threshold
y
(Dilation)	&	 (Erosion)
Kernel
u(Edge	Detection)
Sobel
## threshold1 threshold2
R 2
1
1 2 e
#intensities 60 R
120
Canny u R
R
u(Edge	Detection)
(Perspective	Transform)
4
A4 1 1.41 a
(Perspective	Transform)
Webcam Sketch
Guassian	Blurs
cap VideoCapture
frame
Image	Segmentation
(Contours)
3
(Sorting	Contours)
Canny
Line	Detection	- Using	Hough	Lines
Canny
1 rho HoughLines
np.pi	/	180 1
240
Line	Detection	- Using	Hough	Lines(2)
Blob	Detection
u
u
u blob
Counting	Circles	and	Ellipses(1)	
u
u
blob
Identifiy Contours	by	Shape(2)
y
y
y
y
y
u
u
u
Object	Detection
(Waldo)
Martin Handford
n
——
D
Finding	Waldo
Finding	Corners
cornerHarris float32
Feature	Detection- SIFT
SIFT	Feature	Detector
u
Feature	Detection- SURF
SURF	Feature	Detector
Feature	Detection- FAST
FAST u #fast	=	cv2.FastFeatureDetector
Feature	Detection-
Oriented	FAST	and	Rotated	BRIEF	(ORB)
ORB
Histogram	of	Oriented	Gradients(1)
h	x	w( )
h	x	w
OpenCV HOG
winSize
hog_feats numpy
Histogram	of	Oriented	Gradients(2)
# R
Matplotlib HOG
360	/	nbins	*3
SIFT	Webcam	Demo
Run	feature_homography.py
u
Face	Detection
u
OpenCV CascadeClassifier
XML-
u ROI
u face_classifier
faces
u
Webcam Demo(1)
Merging	Faces(1)
U
Merging	Faces(2)
x y
Merging	Faces(3)
Merging	Faces(4)
t e
Merging	Faces(5)
Merging	Faces(6)
Merging	Faces(7)
Motion	Analysis- Yawn	Detector	and	Counting
• OpenCV u
•
Yawn	Detector	and	Counting(1)
Yawn	Detector	and	Counting(2)
Yawn	Detector	and	Counting(3)
• OpenCV iPhone X Face	ID
• c
•
• 2D3 3D
• iPhone X (Infrared)
- U
numpy
numpy
U
- Webcam Demo(1)
- Webcam Demo(2)
U u
c
• face_recognition
examples/facerec_
from_webcam.py
Object	Tracking
(Object	Tracking)
• u
• u Video
Tracking 3
• (Optical	Flow)
(Object	Tracking)
u
Lucas	kanade
(Object	Tracking)
1
dsjerry2017@gmail.com
jerry@mail.ntust.edu.tw
dsjerry2017@gmail.com 123
• opencv examples/lk_homography.py
• opencv examples/python3	lk_track.py

廣宣學堂: 機器視覺初探 10152017