简体   繁体   English

如何从SIFT算法产生的描述符中获取图像的关键点或像素坐标

[英]How to get key points or pixel coordinates of an image from descriptor produced by SIFT algorithm

I have used SIFT algorithm to produce descriptor. 我已经使用SIFT算法生成描述符。 After doing some processing to descriptor I got some selected descriptor. 对描述符进行一些处理后,我得到了一些选定的描述符。 Now I want to draw lines between those descriptors, for that I want key points or pixel coordinates back from those descriptors. 现在,我想在这些描述符之间画线,因为我想要从这些描述符返回关键点或像素坐标。

I am trying to implement copy move forgery detection using opencv. 我正在尝试使用opencv实现复制移动伪造检测。 Using key point concept, I got matched pairs of descriptor. 使用关键点概念,我得到了匹配的描述符对。 Just want to draw line between those matched descriptor. 只是想在那些匹配的描述符之间画线。

Code for producing descriptor: 产生描述符的代码:

sift = cv2.xfeatures2d.SIFT_create()
kp2, desc2 ift.detectAndCompute(gtemp,None)

The final descriptor I got, between which I want to draw lines: 我得到的最后一个描述符,我要在它们之间画线:

[ 1. 64. 131. 1. 2. 9. 1. 0. 4. 80. 131. 0. 0. 3. 14. 12. 1. 52. 131. 0. 0. 0. 7. 9. 2. 25. 131. 0. 0. 0. 0. 0. 19. 12. 20. 3. 48. 54. 1. 8. 92. 28. 38. 0. 0. 2. 58. 108. 8. 18. 63. 0. 0. 43. 131. 28. 15. 18. 65. 0. 0. 31. 115. 33. 33. 2. 3. 47. 61. 8. 0. 7. 131. 24. 0. 0. 1. 0. 12. 47. 77. 4. 0. 0. 0. 27. 91. 22. 1. 0. 0. 0. 0. 28. 113. 19. 10. 0. 2. 9. 1. 2. 79. 55. 131. 1. 0. 0. 0. 0. 17. 131. 47. 0. 0. 0. 0. 0. 1. 25. 0. 0. 0. 0. 0. 0. 3. 1.] [ 23. 22. 31. 4. 0. 1. 8. 8. 26. 41. 40. 25. 4. 2. 13. 19. 11. 42. 46. 48. 8. 17. 15. 7. 4. 25. 28. 42. 38. 74. 34. 2. 68. 21. 24. 25. 2. 10. 11. 14. 14. 17. 119. 50. 12. 15. 11. 12. 87. 35. 36. 21. 14. 10. 7. 39. 8. 5. 14. 72. 119. 25. 3. 6. 5. 11. 13. 6. 1. 61. 113. 21. 8. 4. 7. 8. 9. 93. 119. 44. 69. 16. 13. 13. 15. 28. 45. 59. 5. 3. 7. 119. 119. 7. 0. 0. 0. 119. 119. 0. 0. 10. 28. 3. 0. 100. 119. 0. 0. 29. 54. 6. 0. 20. 55. 36. 52. 62. 24. 3. 2. 0. 4. 119. 119. 8. 1. 1.]

I think if I could get pixel coordinates back from this descriptors then it will be easier to draw lines between them. 我认为,如果我可以从这些描述符中获得像素坐标,则在它们之间绘制线条会更容易。 Using python 3.6 with OpenCV. 在OpenCV中使用python 3.6。

I understand that you want to draw lines between the two images that you are matching. 我了解您想在要匹配的两个图像之间画线。
For this purpose OpenCV has cv.drawMatches . 为此,OpenCV具有cv.drawMatches The documentation for this method is here . 此方法的文档在这里

Use it like this image3 = cv2.drawMatches(image1, kp1, image2, kp2, matches, None, flags=2) . 像这样使用它image3 = cv2.drawMatches(image1, kp1, image2, kp2, matches, None, flags=2)

Also if you need pixel coordinates for your matched keypoints you have to read the pt attribute for cv2.KeyPoint . 同样,如果需要像素坐标作为匹配的关键点,则必须读取cv2.KeyPointpt属性。

For example if you want the pixel coordinates of all you matched features in image 2: 例如,如果您想要图像2中所有匹配特征的像素坐标:

for kp in kp2:
    for match in matches:
        print(kp2[match.trainIdx].pt)

In this case match.trainIdx is the id for a match in reference of image2 and the pt attribute refers to the pixel coordinate of that feature point. 在这种情况下, match.trainIdx是参考image2的匹配ID,而pt属性则是该特征点的像素坐标。 The same goes for image1 but you have to read kp1[match.queryIdx].pt . image1也是一样,但是您必须阅读kp1[match.queryIdx].pt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从图像中获取“1 像素宽”坐标? - How to get "1 pixel wide" coordinates from image? 对FITS图像进行过采样后,从ra,dec获取像素坐标 - Get pixel coordinates from ra, dec after oversampling FITS image 从 Python 中的二进制图像获取像素边界坐标(不是边缘) - Get pixel boundary coordinates from binary image in Python (not edges) 在pyrender中将场景渲染为图像后如何获取对象的像素坐标? - How to get pixel coordinates of object after rendering the scene as image in pyrender? 获取光栅图像中所有像素的像素坐标 - get pixel coordinates of all pixels in a raster image GIS / GEOTiff / GDAL / Python 如何从像素获取坐标 - GIS / GEOTiff / GDAL / Python How to get coordinates from pixel 如何从 OpenCV Python 中的特征匹配中获取像素坐标 - How to get pixel coordinates from Feature Matching in OpenCV Python 从整体图像中获取轮廓的像素坐标 - Getting Pixel coordinates of a contour from the overall image SIFT或SURF - 提供关键点和检索描述符 - SIFT or SURF - Provide key points and retrieve descriptors 如何在pyqtgraph中获取绘图线的像素坐标 - How to get the pixel coordinates of a plot line in pyqtgraph
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM