change: dump ocr texts as string in summary

This commit is contained in:
lilong.129
2023-04-28 13:23:52 +08:00
parent 37a984c243
commit 2323015755
2 changed files with 8 additions and 7 deletions

View File

@@ -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
}

View File

@@ -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
}