locateText
Locate text pattern
Description
uses additional options specified by one or more name-value pair arguments.bboxes
= locateText(ocrText
,pattern
,Name,Value
)
Examples
Find and Highlight Text in an Image
businessCard = imread('businessCard.png'); ocrResults = ocr(businessCard); bboxes = locateText(ocrResults, 'MathWorks', 'IgnoreCase', true); Iocr = insertShape(businessCard, 'FilledRectangle', bboxes); figure; imshow(Iocr);
Find Text Using Regular Expressions
businessCard = imread('businessCard.png'); ocrResults = ocr(businessCard); bboxes = locateText(ocrResults, 'www.*com','UseRegexp', true); img = insertShape(businessCard, 'FilledRectangle', bboxes); figure; imshow(img);
Input Arguments
ocrText
— Object containing OCR results
ocrText
object
Recognized text and metrics, returned as an ocrText
object. The object contains the recognized text, the location of the
recognized text within the input image, and the metrics indicating the confidence of the
results. The confidence values range between 0
and 100
and represent a percent probability. When you specify an M-by-4
roi
, the function returns ocrText
as an M-by-1 array of ocrText
objects. Confidence values range between 0 and 1. Interpret the confidence
values as probabilities.
pattern
— OCR character vector pattern
single character vector | cell array of character vectors | string scalar | string array
OCR character vector pattern, specified as a single character vector, string scalar, cell
array of character vectors, or a string array. The method returns only the locations of
bounding boxes which correspond to text within an image that exactly match the input
pattern
.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: 'IgnoreCase',true
specifies case-insensitive text
locations
UseRegexp
— Regular expression
false
(default) | logical scalar
Regular expression, specified as a logical scalar. When you set this property to
true
, the method treats the pattern as a regular expression. For more
information about regular expressions, see regexp
.
IgnoreCase
— Case sensitivity
false
(default) | logical scalar
Case sensitivity, specified as a logical scalar. When you set this property to
true
, the method performs case-insensitive text location.
Output Arguments
bboxes
— Text bounding boxes
method | M-by-4 matrix
Text bounding boxes, returned as an M-by-4 matrix. Each row of the
matrix contains a four-element vector, [x
y
width
height]. The [x
y] elements correspond to the upper-left corner of the bounding box. The
[width
height] elements correspond to the size of the rectangular region in
pixels. The bounding boxes enclose text found in an image using the ocr
function. The ocr
function stores OCR results in the ocrText
object.
Version History
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)