OpenCV has very good documentation on generating SIFT descriptors, but this is a version of "weak SIFT", where the key points are detected by the original Lowe algorithm. The OpenCV example reads something like:
img = cv2.imread('home.jpg')
gray= cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
sift = cv2.SIFT()
kp = sift.detect(gray,None)
kp,des = sift.compute(gray,kp)
What I'm looking for is strong/dense SIFT, which does not detect keypoints but instead calculates SIFT descriptors for a set of patches (e.g. 16x16 pixels, 8 pixels padding) covering an image as a grid. As I understand it, there are two ways to do this in OpenCV:
In other words, I'd have to replace the sift.detect()
line with something that gives me the keypoints I require.
My problem is that the rest of the OpenCV documentation, especially wrt Python, is severely lacking, so I have no idea how to achieve either of these things. I see in the C++ documentation that there are keypoint detectors for grid, but I don't know how to use these from Python.
The alternative is to switch to VLFeat, which has a very good DSift/PHOW implementation but means that I'll have to switch from python to matlab.
Any ideas? Thanks.
SIFT in OpenCV Note that these were previously only available in the opencv contrib repo, but the patent expired in the year 2020. So they are now included in the main repo.
Dense SIFT collects more features at each location and scale in an image, increasing recognition accuracy accordingly. However, computational complexity will always be an issue for it (in relation to normal SIFT).
SIFT (Scale Invariant Fourier Transform) Detector is used in the detection of interest points on an input image. It allows identification of localized features in images which is essential in applications such as: Object Recognition in Images.
You can use Dense Sift in opencv 2.4.6 <. Creates a feature detector by its name.
cv2.FeatureDetector_create(detectorType)
Then "Dense"
string in place of detectorType
eg:-
dense=cv2.FeatureDetector_create("Dense")
kp=dense.detect(imgGray)
kp,des=sift.compute(imgGray,kp)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With