From 23230157551326f27a362e1b9859ac19e4330c3c Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Fri, 28 Apr 2023 13:23:52 +0800 Subject: [PATCH] change: dump ocr texts as string in summary --- hrp/pkg/uixt/ext.go | 12 ++++++------ hrp/pkg/uixt/ocr_vedem.go | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hrp/pkg/uixt/ext.go b/hrp/pkg/uixt/ext.go index 9f6fcf44..2112e168 100644 --- a/hrp/pkg/uixt/ext.go +++ b/hrp/pkg/uixt/ext.go @@ -51,8 +51,8 @@ type DriverExt struct { windowSize Size frame *bytes.Buffer doneMjpegStream chan bool - OCRService IOCRService // used to get texts from image - stepScreenShots map[string]OCRTexts // cache screenshot ocr results, key is image path + OCRService IOCRService // used to get texts from image + stepScreenShots map[string]string // cache screenshot ocr results, key is image path, value is dumped OCRTexts CVArgs } @@ -61,7 +61,7 @@ func NewDriverExt(device Device, driver WebDriver) (dExt *DriverExt, err error) dExt = &DriverExt{ Device: device, Driver: driver, - stepScreenShots: make(map[string]OCRTexts), + stepScreenShots: make(map[string]string), } dExt.doneMjpegStream = make(chan bool, 1) @@ -160,19 +160,19 @@ func (dExt *DriverExt) saveScreenShot(raw *bytes.Buffer, fileName string) (strin return "", errors.Wrap(err, "encode screenshot image failed") } - dExt.stepScreenShots[screenshotPath] = nil + dExt.stepScreenShots[screenshotPath] = "" log.Info().Str("path", screenshotPath).Msg("save screenshot file success") return screenshotPath, nil } -func (dExt *DriverExt) GetScreenShots() map[string]OCRTexts { +func (dExt *DriverExt) GetScreenShots() map[string]string { defer func() { for key := range dExt.stepScreenShots { delete(dExt.stepScreenShots, key) } }() - copied := make(map[string]OCRTexts) + copied := make(map[string]string) for key, value := range dExt.stepScreenShots { copied[key] = value } diff --git a/hrp/pkg/uixt/ocr_vedem.go b/hrp/pkg/uixt/ocr_vedem.go index 28538adc..1558b95f 100644 --- a/hrp/pkg/uixt/ocr_vedem.go +++ b/hrp/pkg/uixt/ocr_vedem.go @@ -291,7 +291,8 @@ func (dExt *DriverExt) GetScreenTextsByOCR() (texts OCRTexts, err error) { return } - dExt.stepScreenShots[imagePath] = ocrTexts + o, _ := json.Marshal(ocrTexts) + dExt.stepScreenShots[imagePath] = string(o) return ocrTexts, nil }