45 lines
1.5 KiB
Go
45 lines
1.5 KiB
Go
package ocr
|
|
|
|
import (
|
|
"context"
|
|
"tyapi-server/internal/domains/certification/dto"
|
|
)
|
|
|
|
// OCRService OCR识别服务接口
|
|
type OCRService interface {
|
|
// 识别营业执照
|
|
RecognizeBusinessLicense(ctx context.Context, imageURL string) (*dto.OCREnterpriseInfo, error)
|
|
RecognizeBusinessLicenseFromBytes(ctx context.Context, imageBytes []byte) (*dto.OCREnterpriseInfo, error)
|
|
|
|
// 识别身份证
|
|
RecognizeIDCard(ctx context.Context, imageURL string, side string) (*IDCardInfo, error)
|
|
|
|
// 通用文字识别
|
|
RecognizeGeneralText(ctx context.Context, imageURL string) (*GeneralTextResult, error)
|
|
}
|
|
|
|
// IDCardInfo 身份证识别信息
|
|
type IDCardInfo struct {
|
|
Name string `json:"name"` // 姓名
|
|
IDCardNumber string `json:"id_card_number"` // 身份证号
|
|
Gender string `json:"gender"` // 性别
|
|
Nation string `json:"nation"` // 民族
|
|
Birthday string `json:"birthday"` // 出生日期
|
|
Address string `json:"address"` // 住址
|
|
IssuingAgency string `json:"issuing_agency"` // 签发机关
|
|
ValidPeriod string `json:"valid_period"` // 有效期限
|
|
Confidence float64 `json:"confidence"` // 识别置信度
|
|
}
|
|
|
|
// GeneralTextResult 通用文字识别结果
|
|
type GeneralTextResult struct {
|
|
Words []TextLine `json:"words"` // 识别的文字行
|
|
Confidence float64 `json:"confidence"` // 整体置信度
|
|
}
|
|
|
|
// TextLine 文字行
|
|
type TextLine struct {
|
|
Text string `json:"text"` // 文字内容
|
|
Confidence float64 `json:"confidence"` // 置信度
|
|
}
|