optimize FindTexts return

This commit is contained in:
buyuxiang
2023-08-26 11:25:08 +08:00
parent 9ea2b9bf00
commit 79988fbf0b

View File

@@ -163,16 +163,16 @@ func (t OCRTexts) FindTexts(texts []string, options ...ActionOption) (results OC
results = append(results, ocrText)
}
if actionOptions.MatchOne && len(results) == 0 {
return nil, errors.Wrap(code.CVResultNotFoundError,
fmt.Sprintf("texts %s not found in %v", texts, t.texts()))
if len(results) == len(texts) {
return results, nil
}
if !actionOptions.MatchOne && len(results) != len(texts) {
return nil, errors.Wrap(code.CVResultNotFoundError,
fmt.Sprintf("texts %s not found in %v", texts, t.texts()))
if actionOptions.MatchOne && len(results) > 0 {
return results, nil
}
return results, nil
return nil, errors.Wrap(code.CVResultNotFoundError,
fmt.Sprintf("texts %s not found in %v", texts, t.texts()))
}
func newVEDEMImageService() (*veDEMImageService, error) {