From bdcc9624341ee34298be74a706b09f12f8306456 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 18 四月 2024 23:16:56 +0800
Subject: [PATCH] 优化缓存的数据, 取消多次的base64计算和float32转换

---
 db/person.go |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/db/person.go b/db/person.go
index 0a567e5..3224daa 100644
--- a/db/person.go
+++ b/db/person.go
@@ -1,6 +1,8 @@
 package db
 
 import (
+	"encoding/base64"
+	"sdkCompare/compare"
 	"strconv"
 )
 
@@ -55,11 +57,16 @@
 
 	for _, p := range persons {
 		if p.FaceFeature != "" {
+			byteFeat, err := base64.StdEncoding.DecodeString(p.FaceFeature)
+			if err != nil {
+				continue
+			}
+
 			arr = append(arr, &FeatureCacheBase{
 				Id:          p.Id,
 				TableId:     p.TableId,
 				AreaId:      p.AreaID,
-				FaceFeature: p.FaceFeature,
+				FaceFeature: compare.ByteSlice2float32Slice(byteFeat),
 				Enable:      int32(p.Enable),
 			})
 		}
@@ -74,12 +81,17 @@
 	if err != nil {
 		return nil, err
 	}
+
 	if p.FaceFeature != "" {
+		byteFeat, err := base64.StdEncoding.DecodeString(p.FaceFeature)
+		if err != nil {
+			return nil, err
+		}
 		info = &FeatureCacheBase{
 			Id:          p.Id,
 			TableId:     p.TableId,
 			AreaId:      p.AreaID,
-			FaceFeature: p.FaceFeature,
+			FaceFeature: compare.ByteSlice2float32Slice(byteFeat),
 			Enable:      int32(p.Enable),
 		}
 	}

--
Gitblit v1.8.0