Created
September 16, 2012 21:59
-
-
Save ahojnnes/3734557 to your computer and use it in GitHub Desktop.
OpenCV - skimage corner detection comparison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from skimage.feature import peak_local_max | |
from skimage.feature.corner import corner_harris, corner_subpix, corner_foerstner | |
from skimage import data | |
from skimage.io import imsave | |
from skimage.util import img_as_float, img_as_ubyte | |
from skimage.color import rgb2gray | |
import pylab as plt | |
import numpy as np | |
import cv2 | |
img = data.checkerboard() | |
harris = corner_harris(img) | |
coords_cv = cv2.goodFeaturesToTrack(img, maxCorners=49, qualityLevel=0.1, minDistance=20) | |
cv2.cornerSubPix(img, coords_cv, (11, 11), (-1, -1), (cv2.TERM_CRITERIA_MAX_ITER | cv2.TERM_CRITERIA_EPS, 20, 0.01)) | |
coords = peak_local_max(harris, min_distance=20, num_peaks=49) | |
corners_subpix = corner_subpix(img, coords) | |
plt.gray() | |
plt.imshow(img, interpolation='nearest') | |
plt.plot(corners_subpix[:, 1], corners_subpix[:, 0], '+r') | |
plt.plot(coords_cv[:, 0, 1], coords_cv[:, 0, 0], '+b') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment