Ask Your Question
0

How to get SIFT features as floating point?

asked 2018-01-02 04:25:39 -0600

varagrawal gravatar image

updated 2018-01-02 04:57:53 -0600

When I run sift.compute (or sift.detectAndCompute), in python3 (via anaconda), the descriptors get truncated to integer arrays instead of floating point.

I am wondering how do I get the descriptors in python as the original floating point numbers?

edit retag flag offensive close merge delete

Comments

" the descriptors come as np.uint8 arrays." -- not so, here. please show, how you arrrive at that.

berak gravatar imageberak ( 2018-01-02 04:40:44 -0600 )edit

I run sift = cv2.xfeatures2d.SIFT_create() and then call kp, desc = sift.detectAndCompute() and I get the descriptors. If it helps, I am using OpenCV 3.1.0.

varagrawal gravatar imagevaragrawal ( 2018-01-02 04:55:28 -0600 )edit

@berak I see what you mean. I have updated my question. Sorry for the confusion.

varagrawal gravatar imagevaragrawal ( 2018-01-02 04:58:10 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2018-01-02 04:58:19 -0600

berak gravatar image

updated 2018-01-02 04:59:59 -0600

SIFT descriptors ARE float, come rain or come shine:

>>> sift = cv2.xfeatures2d.SIFT_create()
>>> im = cv2.imread("img/crack.jpg",0)
>>> im.shape
(379, 500)
>>> kp,des = sift.detectAndCompute(im,None)
>>> des
array([[ 47.,   9.,   6., ...,   0.,   0.,   2.],
       [  8.,   3.,   5., ...,   0.,   7.,  15.],
       [ 28.,  14.,   2., ...,   4.,   2.,   1.],
       ...,
       [ 88.,   6.,   1., ...,  21.,  17.,   5.],
       [ 66.,   5.,   1., ...,  23.,  22.,   7.],
       [  2.,   0.,   0., ...,   2.,   1.,   1.]], dtype=float32)

(those are actually histogram bins, counters, they are integer numbers (in a float array), not truncated at all)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-01-02 04:25:16 -0600

Seen: 1,072 times

Last updated: Jan 02 '18