2021-5-13 23:01:35 [显示全部楼层]
6351浏览
查看: 6351|回复: 0

[求助问答] str数据类型转bytearray数据类型与人脸识别获得对比

[复制链接]
5创造力
本帖最后由 Llfeng16 于 2021-5-14 12:42 编辑

把人脸识别特征值变为str数据保存到sd卡,读出数据不会转bytearray,强制转换提示数据位数不一样,代码如下
读取代码
i = 0
temp_num = ''with open("/sd/renlain7.txt", "r") as f:   
while(1):        
line = f.readline()      
if not line:            
break        
stu_name = line[0:line.index('#')]   #获取姓名
        line = line[line.index('#')+1:]      #截取人脸特征        #buffer=struct.pack("obj",line)
        #str2bytes = line.encode()        #str2bytes.decode('utf-f-8')
        #line=bytearray(str2bytes)        line = line.encode()        print("%s"% line)
        record_ftrs.append(line)       #向人脸特征列表中添加已存特征
        ##if stu_num != temp_num:            ##temp_num = stu_num            ##i = i + 1            ##print("%d:%s%s" % (i,stuname),line)






    保存代码         
record_ftr = feature               
record_ftrs.append(record_ftr) #将当前特征添加到已知特征列表               
print("%s"% (record_ftr))               
with open("/sd/renlain7.txt", "a") as f:                    
   f.write(strname+'#'+str(feature))  #信息写入SD卡
   f.write("\n")                    
   f.close()

出错语句

score = kpu.face_compare(record_ftrs[j], bytes(feature)) #计算当前人脸特征值与已存特征值的分数

}M$4}_I1B}Z8ZK7~}9@)6AC.png
0$6@1_B9KV8NCMR~KA1XR0A.png
GPT29E5WRAR1X34VSTU`Q0C.png
高级模式
B Color Image Link Quote Code Smilies |上传

本版积分规则

为本项目制作心愿单
购买心愿单
心愿单 编辑
[[wsData.name]]

硬件清单

  • [[d.name]]
btnicon
我也要做!
点击进入购买页面
上海智位机器人股份有限公司 沪ICP备09038501号-4

© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed

mail