visual tracking (2)swk/lecture/ic2020/kagami_ic2020...kernel density estimation (kde) shingo kagami...

40
Intelligent Control Systems Visual Tracking (2) โ€” Feature-based Methods โ€” Shingo Kagami Graduate School of Information Sciences, Tohoku University swk(at)ic.is.tohoku.ac.jp http://www.ic.is.tohoku.ac.jp/ja/swk/

Upload: others

Post on 18-Jan-2021

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Intelligent Control Systems

Visual Tracking (2)โ€” Feature-based Methods โ€”

Shingo KagamiGraduate School of Information Sciences,

Tohoku Universityswk(at)ic.is.tohoku.ac.jp

http://www.ic.is.tohoku.ac.jp/ja/swk/

Page 2: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Feature-based Methods vs Direct Methods

3Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

direct comparison of pixel values

comparison of feature values computed from images (e.g.

histograms, edge positions, โ€ฆ)

Page 3: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

General Framework

4Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

featureextraction

similarityfunction maximize

featureextraction

Page 4: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Lucas-Kanade Tracking (last week)

5Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

featureextraction

similarityfunction maximize

featureextraction

Identity function

Identity function

โˆ’ Sum ofSquared

Differences

Gauss-Newton

Page 5: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Histogram-based Mean Shift Tracking

6Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

featureextraction

similarityfunction maximize

featureextraction

histogram

Bhattacharyyacoefficient

Mean Shifting

histogram

Page 6: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

7Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

(Grayscale) Histogram

0 50 100 150 200 250

0

500

1000

1500

2000

2500

3000

u

H(u)

where S(u) is a set of pixels having values belonging to the bin u

(normalized histogram)

Page 7: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

8Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Color Histograms

e.g.1) By splitting each of RGB components into 16 bins, we have histogram over 16 x 16 x 16 bins

e.g.2) By splitting each of Hue and Saturation components into 64 bins (and ignoring Value component), we have histogram over 64 x 64 binsโ€ข Less affected by illumination change

hue

saturation

Page 8: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

9Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Hue-Saturation Histograms

04_color_histogram.py(Also download color_histogram_utils.py and put it in the same folder)

Page 9: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

10Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Weighted Histogramโ€ข The pixels near boundaries should have small influenceโ€ข Discontinuity in the similarity map is not favored

! weight the voting depending of pixel locations

Object Model:

S0(u): set of pixels whose pixel values belong to bin u in the model image

S(u): the same above in the current imagek(): weight function or kernel function

Image coordinates x = (x, y) are normalized such that it fits a unit circle

1โ€“1

โ€“1

1

Histogram of candidate region:

unit circle centered at y

Page 10: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

11Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Kernel Function Examples

e.g.1) Gauss kernel e.g.2) Epanechnikov kernel

Page 11: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

12Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Similarity of Histograms

โ€ข Our objective is to find a region with histogram similar to that of a given model

โ€ข How do we measure the similarity?

Bhattacharyya Coefficientโ€ข is a metric for similarity of two probabilistic distributions

(and thus, of two normalized histograms) p and q

โ€ข Geometric interpretation: inner product of and ,

which lie on the unit sphere surface

Why not other similarity measure?: Simply because this is convenient for the mean shift method

Page 12: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

13Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Similarity Map with Weighted Histogram

current imageobject model

similarity map

04_color_histogram_similarity.py (and color_histogram_utils.py)

model histogram

Page 13: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Dictionary in Python

14Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

dic = { "a": 123, "b": (10, 20), "c": "Foo" }dic["a"]

-> 123dic["b"]

-> (10, 20)dic["c"] = "Bar"dic["c"]

-> 'Bar'

cf. lis = [123, (10, 20), "Foo"]lis[0]

-> 123lis[1]

-> (10, 20)lis[2]

-> 'Foo'

Page 14: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Kernel Density Estimation (KDE)

15Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Given data samples ๐’™๐’™๐‘–๐‘– with weights ๐‘ค๐‘ค(๐’™๐’™๐‘–๐‘–) drawn from an unknown probability distribution ๐‘๐‘(๐’š๐’š), KDE (or Parzenestimation) of ๐‘๐‘(๐’š๐’š) is given by

k(): kernel function

x1 x2 xNy

kernel around x2 illustration when ๐‘ค๐‘ค ๐’™๐’™๐‘–๐‘– โ‰ก 1

โ€ข Since brute-force search for maximum similarity is too time consuming, letus think of using a gradient-based method

โ€ข We introduce Mean Shift Method that finds a local maximum of probability density distribution estimated through data samples [Fukunaga 1975]

Page 15: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

16Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Mean Shift Methodโ€ข An efficient method to find a local maximum of a probability

distribution estimated by KDE

Gradient at y:

Defining ๐‘”๐‘” ๐‘ฅ๐‘ฅ = โˆ’๐‘˜๐‘˜โ€ฒ ๐‘ฅ๐‘ฅ , we have

๐‘“๐‘“๐‘”๐‘”(๐’š๐’š): KDE with kernel g()

๐’Ž๐’Ž๐‘”๐‘” ๐’š๐’š : mean shift vector

Page 16: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Interpretation of Mean Shift Vector

17Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

When Epanechnikov kernel is used as ๐‘˜๐‘˜, ๐‘”๐‘” = โˆ’๐‘˜๐‘˜โ€ฒ becomes 1 within the unit circle around y, and 0 otherwise.

center of gravity within unit circle

Page 17: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

18Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Mean Shift Method

1. Compute center of gravity of samples around current position2. Move to the center of gravity (mean shifting)3. Return to 1. unless the mean shift vector becomes too small

โ€ข Mean shift vector is toward the direction fk(y) becomes largerโ€ข Mean shift vector is large when fg(y) is small (i.e. goal may be

further), and small when fg(y) is large (i.e. goal may be closer)

Recalling that (i.e. ), we see

Procedure of Mean Shift Method with Epanechnicov kernel:

Page 18: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

19Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Approximating the Histogram SimilarityComing back to the tracking problem, consider approximating the Bhattacharyya coefficient ๐œŒ๐œŒ(p(y), q) such that it fits the Mean Shift framework

โ€ข Let y0 denote the initial candidate position โ€ข Consider 1st order Taylor expansion to ๐œŒ๐œŒ(p(y), q) with

respect to p(y) around p(y0)

Page 19: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

20Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Since the 1st term does not depend on y, what we should maximize is the 2nd term:

Recalling that , this comes down to

where b(x) is the bin to which x belongs.

maximization of

Page 20: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

21Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

So, what we should maximize is:

For each pixel x (in the kernel range), find b(x) to look up q and p, and compute w(x).

KDE with kernel k()where the pixels are treated as samples

histogram of region around y0

model histogram

b(x)

b(x)

qb(x)

pb(x)(y0)

Page 21: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

22Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Mean Shift Tracking [Comaniciu 2003]

1. Compute the weighted histogram p(y0) around y02. Move y0 to the center of gravity of w(x), by finding b(x) and

looking up q an p for each pixel x around y03. Return to 1. unless the move becomes too small

histogram of region around y0

model histogram

b(x)

b(x)

qb(x)

pb(x)(y0)

Page 22: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

23Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

04_mean_shift_color_histogram.py (and color_histogram_utils.py)

Page 23: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Further Examples

Page 24: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

General Framework

25Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

featureextraction

similarityfunction maximize

featureextraction

what kind of feature?

how to measure similarity?

how to optimize?

Page 25: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

26Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

featureextraction

similarityfunction maximize

โ€ข brute-force search over entire imageโ€ข brute-force search in a local search areaโ€ข brute-force search over feature pointsโ€ข gradient-based searchโ€ข โ€ฆ

โ€ข histogram of colorsโ€ข histogram of gradient

orientationsโ€ข responses from linear

filtersโ€ข comparisons of pixel pairsโ€ข โ€ฆ

โ€ข L2 distance (Euclid distance)โ€ข L๐‘›๐‘› distanceโ€ข Correlationโ€ข Bhattacharyya coefficientโ€ข Kullback-Leibler divergenceโ€ข โ€ฆ

targetfeature

imageor

image region

Page 26: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Further Generalization

27Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

featureextraction

imageor

image regionfeatureanalysis

โ€ข object category (recognition task)โ€ข is target object or not (detection task)โ€ข incremental position update (tracking task)โ€ข candidate region proposalโ€ข โ€ฆ

targetfeature

โ€œExtraction + analysisโ€ can possibly be learnt in an end-to-end manner, particularly when deep learning methods are used

Page 27: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Face Detection Example

28Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Haar-like features

Brute-force scanning of

candidate regions

featureextraction

imageor

image regionfeatureanalysis

targetfeature

Support Vector Machine Classifier

Is faceor not

Page 28: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Haar-like features

29Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

https://docs.opencv.org/master/d2/d64/tutorial_table_of_content_objdetect.html

โ€ข Convolving an image with such box-shaped kernels at many image positions can be accelerated through a technique called the โ€œintegral imageโ€

โ€ข Feature value obtained from a single kernel has little information, but aggregating many of them works well for face detection [Viola 2001]

Page 29: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Person Detection Example

30Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Histogram of Oriented Gradients (HOG)

Brute-force scanning of

candidate regions

featureextraction

imageor

image regionfeatureanalysis

targetfeature

Support Vector Machine (SVM) Classifier

Is person or not

Page 30: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Histogram of Spatial Gradient Orientations

31Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

๐ผ๐ผ ๐ผ๐ผ๐‘ฅ๐‘ฅ ๐ผ๐ผ๐‘ฆ๐‘ฆ Hue โˆ atan ๐ผ๐ผ๐‘ฅ๐‘ฅ๐ผ๐ผ๐‘ฆ๐‘ฆ

+ ๐œ‹๐œ‹

Saturation = 1

Value โˆ ๐ผ๐ผ๐‘ฅ๐‘ฅ2 +๐ผ๐ผ๐‘ฆ๐‘ฆ2

gradient orientation histograms visualized

Often referred to as HOG (Histogram of Oriented Gradients) when combined with local block-wise normalization [Datal 2005]

Page 31: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Local Image Features around Keypoints

32Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

featureextraction

similarityfunction minimize

imagekeypoint

candidate

targetkeypointfeature

descriptor

keypoint feature descriptor(e.g. SIFT, BRISK, ORB, AKAZE, โ€ฆ)

โ€ข L2 distanceโ€ข Hamming distanceโ€ข โ€ฆ

โ€ข Brute-force scanning of keypointsโ€ข Nearest-neighbor search in feature

spaceโ€ข โ€ฆ

matched keypoint

Page 32: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

SIFT Keypoint [Lowe 2004]

33Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

sigma

Laplacian

Laplacian

Laplacian

Laplacian

Gaussian

Gaussian

Gaussian

xy

Keypoint Detectionโ€ข Locate peaks in (x, y, sigma)

spaceโ€ข Eliminate edge responses (by

analyzing 2x2 Hessian matrix)

keypoint at (e.g.)(x = 203, y = 53, sigma = 10)

Page 33: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

SIFT Local Image Descriptor [Lowe 2004]

34Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

Given a keypoint at (x, y, sigma):Orientation Assignment:โ€ข Look at the patch around the point with the

size determined by sigmaโ€ข Find the dominant orientation by finding

peak in gradient histogram

Feature Descriptor Computation:โ€ข The patch is aligned to the dominant

orientationโ€ข Compute the gradient orientation

histograms with 8 orientation bins in 4x4 cells, resulting in 128-D feature vector that is invariant to scale and rotation

โ€ข This procedure (and the resulting feature vector itself) is called Scale Invariant Feature Transformation (SIFT)

โ€ข Useful in point-to-point matching of images

Page 34: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Plane Tracking Example by Keypoint Matching

35Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

SIFT keypoint matching Estimation of homographytransformation using the matched keypoint pairs

โ€ข More recent approaches (e.g. BRISK, ORB, AKAZE, โ€ฆ) generate binary valued feature vector through comparisons of pairs of pixel values

04_keypoint_match.py

Page 35: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Face Landmark Alignment Example [Kazemi 2014]

36Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

differences between pixel pairs

incremental updates of landmark positions

featureextraction

imageor

image regionfeatureanalysis

targetfeature

Ensemble of Regression Trees

landmarkpositions

Page 36: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Preparation for Face Landmark Alignment

37Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

pip install dlib

โ€ข Before trying the sample code for face alignment, run the following command in the command prompt opened by C:ยฅic2020ยฅic_python_env.bat (This may take 10 minutes or so)

โ€ข Then download shape_predictor_68_face_landmarks.dat.bz2 from http://dlib.net/files/, uncompress it, and put it in the sample directory (This consumes 100 MB or so)

โ€ข Now you are ready to run: 04_face_landmarks.py

Page 37: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Object Detection/Recognition Example

38Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

None (You Only Look Once!)

featureextraction

grid cellsin image

featureanalysis

targetfeature

โ€ข Bounding box (with confidence) generation networkโ€ข Object class probability estimation network

object bounding boxes and categories

YOLO [Redmon 2016]

Page 38: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Preparation for YOLO v3

39Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

pip install pillowpip install tensorflow==1.13.1pip install keras==2.2.4

โ€ข Run the following command in the command prompt opened by C:ยฅic2020ยฅic_python_env.bat (which requires 350 MB disk space)

โ€ข Download https://github.com/qqwweee/keras-yolo3 in zip file and extract somewhere (say, C:ยฅic2020ยฅkeras-yolo3). Or, you can use git

git clone https://github.com/qqwweee/keras-yolo3

โ€ข Download https://pjreddie.com/media/files/yolov3.weights into C:ยฅic2020ยฅkeras-yolo3. File size is 250 MB and downloading may take long time.

python convert.py yolov3.cfg yolov3.weights model_dataยฅyolo.h5

โ€ข Run the following command in C:ยฅic2020ยฅkeras-yolo3 (which generate another 250-MB file)

Page 39: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

Running YOLO v3

40Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

import sysfrom yolo import YOLOfrom yolo import detect_video

if __name__ == '__main__':cap_src = 'vtest.avi'if len(sys.argv) == 2:

if sys.argv[1].isdecimal():cap_src = int(sys.argv[1])

else:cap_src = sys.argv[1]

detect_video(YOLO(), cap_src)

python yolo_cam.py path_to_a_video_file_or_camera_number

โ€ข Put the above program into a file yolo_cam.py in C:ยฅic2020ยฅkeras-yolo3, and run the following

Page 40: Visual Tracking (2)swk/lecture/ic2020/kagami_ic2020...Kernel Density Estimation (KDE) Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4) 15 Given data samples ๐’™๐’™

References

41Shingo Kagami (Tohoku Univ.) Intelligent Control Systems 2020 (4)

โ€ข D. Comaniciu, V. Ramesh and P. Meer: Kernel-Based Object Tracking, IEEE Trans. on Pattern Analysis and Machine Intelligence, vol.25, no.5, 2003.

โ€ข D. Comaniciu and P. Meer: Mean Shift: A Robust Approach Toward Feature Space Analysis, IEEE Trans. on Pattern Analysis and Machine Intelligence, vol.25, no.5, 2003.

โ€ข K. Fukunaga and L. D. Hostetler: The Estimation of the Gradient of a Density Function, with Applications in Pattern Recognition, IEEE Trans. on Information Theory, vol.IT-21, no.1, 1975.

โ€ข N. Dalal and B. Triggs: Histograms of Oriented Gradients for Human Detection, IEEE Conf. on Computer Vision and Pattern Recognition (CVPR 2005), 2005.

โ€ข P. Viola and M. J. Jones: Rapid Object Detection Using a Boosted Cascade of Simple Features. IEEE Conf. on Computer Vision and Pattern Recognition (CVPR 2001), 2001.

โ€ข D. G. Lowe: Distinctive Image Features from Scale-Invariant Keypoints, International J. of Computer Vision, vol.60, no.2, 2004.

โ€ข V. Kazemi and J. Sullivan: One Millisecond Face Alignment with an Ensemble of Regression Trees, IEEE Conf. on Computer Vision and Pattern Recognition (CVPR 2014), 2014.

โ€ข J. Redmon, S. Divvala, R. Girshick and A. Farhadi: You Only Look Once: Unified, Real-Time Object Detection, IEEE Conf. on Computer Vision and Pattern Recognition (CVPR 2016), 2016.