Skip to content

Commit

Permalink
Don't do the conversion in a goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
vegarsti committed Apr 5, 2024
1 parent 9135fb2 commit 5616cc3
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions cmd/lambda/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ func getTable(file *extract.File) ([][]string, error) {
return nil, fmt.Errorf("failed to convert to boxes: %w", err)
}
rows, table := box.ToTable(boxes)
log.Printf("ocr-to-table: %s", time.Since(startAlgorithm).String())

// Create images with words and cells
go func() {
func() {
if file.ContentType == extract.PNG {
imageWithWords, err := image.AddBoxes(file.Bytes, boxes)
if err != nil {
Expand All @@ -182,10 +183,6 @@ func getTable(file *extract.File) ([][]string, error) {
}
}()

log.Printf("ocr-to-table: %s", time.Since(startAlgorithm).String())
if err != nil {
return nil, fmt.Errorf("failed to convert to table: %w", err)
}
tableBytes, err = json.MarshalIndent(table, "", " ")
if err != nil {
return nil, fmt.Errorf("failed to convert table to json: %w", err)
Expand Down

0 comments on commit 5616cc3

Please sign in to comment.