⬆️ upgrade dependencies
This commit is contained in:
@@ -86,7 +86,7 @@ func (l *FaceRecognitionLogic) FaceRecognition(in *pb.FaceRecognitionRequest) (*
|
||||
l.svcCtx.FaceRecognizer.SetSamples(samples, ids)
|
||||
|
||||
// 人脸分类
|
||||
classify := l.svcCtx.FaceRecognizer.ClassifyThreshold(faceFeatures.Descriptor, 0.3)
|
||||
classify := l.svcCtx.FaceRecognizer.ClassifyThreshold(faceFeatures.Descriptor, 0.2)
|
||||
if classify > 0 {
|
||||
return &pb.FaceRecognitionResponse{
|
||||
FaceId: int64(classify),
|
||||
@@ -242,10 +242,10 @@ func (l *FaceRecognitionLogic) saveCroppedFaceToLocal(faceImage []byte, rect ima
|
||||
// 增加边距(比如 20 像素)
|
||||
margin := 20
|
||||
extendedRect := image.Rect(
|
||||
max(rect.Min.X-margin, imgBounds.Min.X), // 确保不超出左边界
|
||||
max(rect.Min.Y-margin, imgBounds.Min.Y), // 确保不超出上边界
|
||||
min(rect.Max.X+margin, imgBounds.Max.X), // 确保不超出右边界
|
||||
min(rect.Max.Y+margin, imgBounds.Max.Y), // 确保不超出下边界
|
||||
max(rect.Min.X-margin, imgBounds.Min.X),
|
||||
max(rect.Min.Y-margin, imgBounds.Min.Y),
|
||||
min(rect.Max.X+margin, imgBounds.Max.X),
|
||||
min(rect.Max.Y+margin, imgBounds.Max.Y),
|
||||
)
|
||||
// 裁剪图像
|
||||
croppedImage := img.(interface {
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package aiservicelogic
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"image"
|
||||
|
||||
"schisandra-album-cloud-microservices/app/aisvc/rpc/internal/svc"
|
||||
"schisandra-album-cloud-microservices/app/aisvc/rpc/pb"
|
||||
@@ -25,12 +27,15 @@ func NewImageClarityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Imag
|
||||
|
||||
// ImageClarity 图像清晰度检测
|
||||
func (l *ImageClarityLogic) ImageClarity(in *pb.ImageClarityRequest) (*pb.ImageClarityResponse, error) {
|
||||
blurred, confidence, err := l.svcCtx.Clarity.Detect(in.Image)
|
||||
img, _, err := image.Decode(bytes.NewReader(in.Image))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
check, err := l.svcCtx.ClarityDetector.ClarityCheck(img)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &pb.ImageClarityResponse{
|
||||
IsBlurred: blurred,
|
||||
Confidence: float32(confidence),
|
||||
IsBlurred: check,
|
||||
}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user