From 79988fbf0b088a2db9eb2a8ee2363e5949444cd8 Mon Sep 17 00:00:00 2001 From: buyuxiang <347586493@qq.com> Date: Sat, 26 Aug 2023 11:25:08 +0800 Subject: [PATCH] optimize FindTexts return --- hrp/pkg/uixt/service_vedem.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hrp/pkg/uixt/service_vedem.go b/hrp/pkg/uixt/service_vedem.go index bb55d911..2c8f38bb 100644 --- a/hrp/pkg/uixt/service_vedem.go +++ b/hrp/pkg/uixt/service_vedem.go @@ -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) {