| 4 | |
| 5 | |
| 6 | class HARRIS: |
| 7 | def __init__(self, blockSize=2, apertureSize=3, k=0.1, T=0.02): |
| 8 | self.blockSize = blockSize |
| 9 | self.apertureSize = apertureSize |
| 10 | self.k = k |
| 11 | self.T = T |
| 12 | |
| 13 | def detect(self, img): |
| 14 | # convert our input image to a floating point data type and then |
| 15 | # compute the Harris corner matrix |
| 16 | gray = np.float32(img) |
| 17 | H = cv2.cornerHarris(gray, self.blockSize, self.apertureSize, self.k) |
| 18 | |
| 19 | # for every (x, y)-coordinate where the Harris value is above the |
| 20 | # threshold, create a keypoint (the Harris detector returns |
| 21 | # keypoint size a 3-pixel radius) |
| 22 | kps = np.argwhere(H > self.T * H.max()) |
| 23 | kps = [cv2.KeyPoint(pt[1], pt[0], 3) for pt in kps] |
| 24 | |
| 25 | # return the Harris keypoints |
| 26 | return kps |
no outgoing calls
no test coverage detected
searching dependent graphs…