plot: Plot the results of an OCR

plotR Documentation

Plot the results of an OCR

Description

These functions are useful diagnostics of how well the OCR recognized the text. The method for a TesseractBaseAPI object can display both the image and all of the locations and rectangular regions (but not the text) for the elements the OCR recognized. The method for OCRResults (returned from a call to GetBoxes) displays the text returned from the OCR as it appears on the page. In other words, it doesn't show the background image but does show the text. showPoints can be used to highlight a subset of entries in the results of the OCR that are of interest. The function draws large circles centered at those points so one can quickly identify them visually on the original image.

Usage

showPoints(x, top = par()$usr[4], radii = top* 0.05, fg = "red",
            inches = FALSE, addGuides = !inches, ...)

Arguments

x

the subset of the matrix or data.frame of results from the OCR giving the coordinates of the items we want to identify via showPoints

top

the number of pixels in the image, providing the value to map the vertical coordinates in x to the coordinates of the plot, i.e. subtract the values from this top value.

radii

the radius of the circles that are drawn at the points in x. This value is passed to in the call to symbols as the argument for radii.

fg

the color for drawing the circles

inches

a logical value. See inches in the help for symbols

addGuides

a logical value that controls whether we add 3 lines from the center of each point being shown/highlighted to help visually identify the circle and the corresponding text.

...

additional arguments passed to symbols

Value

The plot methods return the matrix of bounding boxes with values consistent with the user-coordinates of the plot (i.e., the top and bottom mapped to the plot's coordinates rather than the top as 0). This can be used to further annotate the plot, e.g., enhance the rectangles for the bounding box elements using rect.

Author(s)

Duncan Temple Lang

See Also

tesseract Recognize


duncantl/Rtesseract documentation built on March 25, 2022, 5:50 a.m.