Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python,将str转换为描述符surf类型_Python_Opencv_Surf_Descriptor - Fatal编程技术网

Python,将str转换为描述符surf类型

Python,将str转换为描述符surf类型,python,opencv,surf,descriptor,Python,Opencv,Surf,Descriptor,我想从数据库中读取surf类型的描述符,并使用它与使用surf方法的图像进行比较,问题是如何将描述符从字符串转换为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 WHE

我想从数据库中读取surf类型的描述符,并使用它与使用surf方法的图像进行比较,问题是如何将描述符从字符串转换为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” 回溯(最近一次呼叫最后一次): 文件“surf v2.py”,第138行,在 desc2=numpy.array(描述符,dtype=numpy.float32)。重塑((1,1)) ValueError:float()的文本无效:[1.55181286e-03 1.55181286e-03-2.10662147e-05…,1.82572391e-03 0.00000000 E+00 0.00000000 E+00] [7.83637588e-05 1.05563842e-03 3.83123639e-03…,1.95306598e-03 0.0000000

退出代码:1


这取决于字符串的外观。可能会起作用。否则,请检查字符串是如何创建的,并使用反向函数