基础架构
This commit is contained in:
@@ -2,23 +2,31 @@ package ocr
|
||||
|
||||
import (
|
||||
"context"
|
||||
"tyapi-server/internal/domains/certification/dto"
|
||||
"tyapi-server/internal/application/certification/dto/responses"
|
||||
)
|
||||
|
||||
// OCRService OCR识别服务接口
|
||||
type OCRService interface {
|
||||
// 识别营业执照
|
||||
RecognizeBusinessLicense(ctx context.Context, imageURL string) (*dto.OCREnterpriseInfo, error)
|
||||
RecognizeBusinessLicenseFromBytes(ctx context.Context, imageBytes []byte) (*dto.OCREnterpriseInfo, error)
|
||||
RecognizeBusinessLicense(ctx context.Context, imageBytes []byte) (*responses.BusinessLicenseResult, error)
|
||||
|
||||
// 识别身份证
|
||||
RecognizeIDCard(ctx context.Context, imageURL string, side string) (*IDCardInfo, error)
|
||||
RecognizeIDCard(ctx context.Context, imageBytes []byte, side string) (*responses.IDCardResult, error)
|
||||
|
||||
// 通用文字识别
|
||||
RecognizeGeneralText(ctx context.Context, imageURL string) (*GeneralTextResult, error)
|
||||
RecognizeGeneralText(ctx context.Context, imageBytes []byte) (*responses.GeneralTextResult, error)
|
||||
|
||||
// 从URL识别图片
|
||||
RecognizeFromURL(ctx context.Context, imageURL string, ocrType string) (interface{}, error)
|
||||
|
||||
// 验证营业执照结果
|
||||
ValidateBusinessLicense(result *responses.BusinessLicenseResult) error
|
||||
|
||||
// 验证身份证结果
|
||||
ValidateIDCard(result *responses.IDCardResult) error
|
||||
}
|
||||
|
||||
// IDCardInfo 身份证识别信息
|
||||
// IDCardInfo 身份证识别信息(保留兼容性)
|
||||
type IDCardInfo struct {
|
||||
Name string `json:"name"` // 姓名
|
||||
IDCardNumber string `json:"id_card_number"` // 身份证号
|
||||
@@ -31,7 +39,7 @@ type IDCardInfo struct {
|
||||
Confidence float64 `json:"confidence"` // 识别置信度
|
||||
}
|
||||
|
||||
// GeneralTextResult 通用文字识别结果
|
||||
// GeneralTextResult 通用文字识别结果(保留兼容性)
|
||||
type GeneralTextResult struct {
|
||||
Words []TextLine `json:"words"` // 识别的文字行
|
||||
Confidence float64 `json:"confidence"` // 整体置信度
|
||||
|
||||
Reference in New Issue
Block a user