160 likes | 167 Views
This article provides a description and implementation of the Harris Algorithm for feature extraction in images and videos. It explains the mathematical principles behind the algorithm and showcases the results obtained through its implementation.
E N D
Extração de Feições Carlos Oliveira coliveira@inf.puc-rio.br
Sumário • Descrição e Objetivo • Algoritmo de Harris • Implementação • Resultados obtidos
Descrição e Objetivo • Capturar um vídeo de uma Webcam ou lê-lo a partir de um arquivo de vídeo • Processamento frame a frame, detectando cantos utilizando o algoritmo de Harris
Window function Shifted intensity Intensity Window function w(x,y) = or 1 in window, 0 outside Gaussian Algoritmo de Harris: Mathematics Change of intensity for the shift [u,v]:
Harris Detector: Mathematics For small shifts [u,v] we have a bilinear approximation: where M is a 22 matrix computed from image derivatives:
Harris Detector: Geometric Interpretation 1, 2 – eigenvalues of M (max)-1/2 (min)-1/2
Harris Detector: Mathematics “Edge” 2 >> 1 2 Classification of image points using eigenvalues of M: “Corner”1 and 2 are large,1 ~ 2;E increases in all directions 1 and 2 are small;E is almost constant in all directions “Edge” 1 >> 2 “Flat” region 1
Harris Detector: Mathematics Measure of corner response: (k – empirical constant, k = 0.04-0.06)
“Edge” “Corner” R < 0 R > 0 “Flat” “Edge” |R| small R < 0 1 Harris Detector: Mathematics 2 • R depends only on eigenvalues of M • R is large for a corner • R is negative with large magnitude for an edge • |R| is small for a flat region
Algoritmo • Comparação dos gráficos 2 “Edge” “Corner” R < 0 R > 0 “Flat” “Edge” |R| small R < 0 1
Algoritmo • Comparação dos gráficos 2 “Edge” “Corner” R < 0 R > 0 “Flat” “Edge” |R| small R < 0 1
Algoritmo • Comparação dos gráficos 2 “Edge” “Corner” R < 0 R > 0 “Flat” “Edge” |R| small R < 0 1
Harris Detector • The Algorithm: • Find points with large corner response function R (R > threshold) • Take the points of local maxima of R
Harris Detector: Summary • Average intensity change in direction [u,v] can be expressed as a bilinear form: • Describe a point in terms of eigenvalues of M:measure of corner response • A good (corner) point should have a large intensity change in all directions, i.e. R should be large positive
Implementação • Foi utilizada a biblioteca OpenCV • No loop principal os frames são capturados • Cada frame lido/capturado é convertido para uma imagem grayscale • Após isso a função cvGoodFeaturesToTrack é chamada passando por parâmetro um flag indicando que ela deve fazer a detecção usando o algoritmo de Harris • Na interface também há a opção de ajustar a qualidade e a quantidade de cantos a detectar