我使用Android中的ORB检测器计算图像的关键点并转换json字符串,我需要发送一个在python上运行的服务器。在Android设备上转换的json字符串看起来像
[
{"class_id":-1,"x":208.0,"y":2492.0,"size":31.0,"angle":312.0059,"octave":0,"response":1.2840814E-4},
{"class_id":-1,"x":114.0,"y":1898.0,"size":31.0,"angle":312.86102,"octave":0,"response":1.4190769E-4},
{"class_id":-1,"x":1519.0,"y":701.0,"size":31.0,"angle":252.71167,"octave":0,"response":7.2368234E-4},
...
]
我无法使用python
从此字符串将其转换为MatOfKeyPoint我正在使用的代码是
res = json.loads((s).decode("utf-8") )
size = len(res)
kpArray = [dict() for x in range(0,size)]
for x1 in xrange(0,size):
#print(type(res[x1]['x']))
kpArray[x1]['pt'] = (res[x1]['x'],res[x1]['y'])
kpArray[x1]['angle'] = res[x1]['angle']
kpArray[x1]['class_id'] = res[x1]['class_id']
kpArray[x1]['size'] = res[x1]['size']
kpArray[x1]['angle'] = res[x1]['angle']
kpArray[x1]['octave'] = res[x1]['octave']
kpArray[x1]['response'] = res[x1]['response']