无论是在外部或本地过程中保存的代码,还是整个过程库或程序的代码,都可以设置密码保护。 因此,可以在不泄露程序代码的情况下共享功能。 所有可序列化的 HALCON 数据也可以用密码进行加密和保护。 这可以直接保护自己的知识产权(例如,已训练的深度学习模型),保护包含知识产权的标志性数据,或者包括关键安全信息的字符串。
操作流程为:
加密流程:
1) 创建字典密码
2)序列化目标
3)加密序列化目标
4)存储加密项目
解密流程:
1)读取加密后的文件解密
2)解密加密目标
3)反序列化后目标
案例分析1
tuple_environment ('HALCON_PASSWORD', Password)
Secret := dict{password: Password}
imagex:=[0,0,1000,1000]
imagey:=[0,1000,0,1000]
worldx:=[0,0,10,10]
worldy:=[0,10,0,10]
vector_to_hom_mat2d (imagex, imagey, worldx, worldy, HomMat2D)
serialize_hom_mat2d (HomMat2D, SerializedItemHandle2)
encrypt_serialized_item (SerializedItemHandle2, Secret, EncryptedItemHandle2)
write_encrypted_item (EncryptedItemHandle2, 'HomMat2D.henc')
read_encrypted_item ('HomMat2D.henc', EncryptedItemHandle3)
decrypt_serialized_item (EncryptedItemHandle3, Secret, SerializedItemHandle3)
deserialize_hom_mat2d (SerializedItemHandle3, HomMat2D1)
案例分析2
Tuple := ['abs', '测试', '123', '???///、、、', 'ASD']
serialize_tuple (Tuple, SerializedItemHandle2)
encrypt_serialized_item (SerializedItemHandle2, Secret, EncryptedItemHandle2)
write_encrypted_item (EncryptedItemHandle2, 'tuple.henc')
read_encrypted_item ('tuple.henc', EncryptedItemHandle3)
decrypt_serialized_item (EncryptedItemHandle3, Secret, SerializedItemHandle3)
deserialize_tuple (SerializedItemHandle3, Tuple1)
案例分析3
read_dl_model ('pretrained_dl_classifier_compact.hdl', DLModelHandle)
serialize_dl_model (DLModelHandle, SerializedItemHandle)
encrypt_serialized_item (SerializedItemHandle, Secret, EncryptedItemHandle)
write_encrypted_item (EncryptedItemHandle, 'dl_model.henc')
read_encrypted_item ('dl_model.henc', EncryptedItemHandle1)
decrypt_serialized_item (EncryptedItemHandle1, Secret, SerializedItemHandle1)
deserialize_dl_model (SerializedItemHandle1, DLModelHandle1)
标签:功能,加密,serialized,encrypted,henc,dl,Halcon,item,Secret
From: https://blog.csdn.net/2202_75557553/article/details/144153649