Identify text area in image and crop it in R

Is there a way in R (R Studio) to identify the text area in the image and crop it? Like I need to locate the license plate only and crop it then extract the text using tesseract. Thank you.


It's going to be difficult, as shown in the sample below, trying OCR on the full image, an image cropped programmatically but with height/width and cropped area set by hand and of a manual screenshot.

eng <- tesseract("eng")
text <- tesseract::ocr("", engine = eng)
#> oF
#> — —

#> Linking to ImageMagick
#> Enabled features: fontconfig, freetype, fftw, heic, lcms, pango, webp, x11
#> Disabled features: cairo, ghostscript, raw, rsvg
#> Using 12 threads
img <- image_read("")

cropped <- image_crop(img, "320x100+150+100")

tesseract::ocr(cropped, engine = eng)
#> [1] ""

shot <- image_read("~/Desktop/Screenshot from 2022-01-01 11-09-34.png")

tesseract::ocr(shot, engine = eng)
#> [1] "WOR SIGK |\n"
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.