I have an image that contains ~400 dots. I've been using the Simpleblob detector to find the keypoints. I then for loop over all keypoints to find the center of each of the keypoints (code below). This works well, but I'm also interested in the moment information, as I would imagine .pt is only averaging the position of all of the pixels associated with the keypoints.
import cv2
import numpy as np
import csv
im = cv2.imread("8f3secshim.bmp", cv2.IMREAD_GRAYSCALE)
detector = cv2.SimpleBlobDetector_create()
keypoints = detector.detect(im)
im_with_keypoints = cv2.drawKeypoints(im, keypoints, np.array([]),
(0,0,255), cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS)
cv2.imshow("Keypoints", im_with_keypoints)
x = np.empty([len(keypoints), 2])
for i in range(len(keypoints)):
x[i] = keypoints[i].pt
I wanted to do something along the lines of this:
M = np.empty([lens(keypoints), 1])
for j in range(len(keypoints)):
M[j] = cv2.moments(keypoints[j])
but it fails.
I've tried abandoning the Simpledetector and using a treatment for moments listed here http://docs.opencv.org/trunk/dd/d49/tutorial_py_contour_features.html , but that has failed as well.
If anyone has any suggestions they would be much appreciated.