Search code examples
pythonopencvimage-processingcomputer-visionsift

Extract keypoints from sift detector


I am using sift detector (cv2.sift.detectAndCompute(image,None))to extract keypoints from an image. It returns the keypoints in form of smart pointers with shared ownership template

`struct cv::Ptr< T >`

How can i extract those keypoints in python to save them in a csv format?


Solution

  • The descriptors of detected keypoints that you obtain, are in a list, for example:

    [[ 42 218 124 ..., 159  69 207]
     [243  30  11 ...,  72  48 117]
     [ 45 201 236 ..., 223 216 232]
     ..., 
     [ 58   5 226 ..., 253 248 130]
     [ 44 110 154 ...,  93 124 154]
     [  7 235  19 ..., 122 161 169]]
    

    The descriptor of the first keypoint looks similar to this:

    [ 42 218 124  95  46 153 182 234 204   6 124 162  41  24 183  32 206  51 167  67 198 169 103 253   6  79 112 147  87 159  69 207]
    

    In order to export these values to csv format using python, there are two ways:

    1. Using XlsxWriter
    2. and Pandas is another option and the most sought after method.