我想从数据库中读取描述符冲浪类型,并使用它与使用冲浪方法的图像进行比较,问题是如何将描述符从字符串转换为ndarray数组
#!/usr/bin/python
detector = cv2.SURF(400, 5, 5)
matcher = cv2.BFMatcher(cv2.NORM_L2)
kp1, desc1 = detector.detectAndCompute(img1, None)
cursor.execute(" SELECT * FROM visage WHERE id=%s", 1)
row = cursor.fetchone()
descriptor=row[6]
desc2=numpy.array(descriptor, dtype = numpy.float32).reshape((1,1))
kp_pairs = match_images(kp1, desc1 , kp2, desc2)
错误是:
pythonw -u“surf v2.py” Traceback(最近一次调用最后一次): 文件“surf v2.py”,第138行,in desc2 = numpy.array(descriptor,dtype = numpy.float32).reshape((1,1)) ValueError:float()的文字无效:[[1.55181286e-03 1.55181286e-03 -2.10662147e-05 ...,1.82572391e-03 0.00000000e + 00 0.00000000e + 00] [7.83637588e-05 1.05563842e-03 3.83123639e-03 ...,1.95306598e-03 0.0000000
退出代码:1