Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5abc649

Browse files
Update README.md
1 parent dd831ce commit 5abc649

File tree

1 file changed

+19
-64
lines changed

1 file changed

+19
-64
lines changed

‎README.md

Lines changed: 19 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,108 +4,63 @@ This repository implements a pretrained Character Region Awareness For Text dete
44

55
[![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=matlab-deep-learning/Text-Detection-using-Deep-Learning)
66

7+
**Creator**: MathWorks Development
8+
79
Requirements
810
------------
911

10-
- MATLAB R2021a or later
12+
- MATLAB R2022a or later
1113
- Deep Learning Toolbox™
1214
- Computer Vision Toolbox™
15+
- Computer Vision Toolbox™ Model for Text Detection
16+
17+
Note: Previous MATLAB release users can use this branch to download the pretrained models.
1318

1419
Overview
1520
--------
1621

17-
This repository implements CRAFT with VGG-16 as backbone. The network is trained on various scene text detection datasets with text in English, Korean, Italian, French, Arabic, German and Bangla (Indian).
22+
This repository implements text detection in images using CRAFT deep learning model with VGG-16 as backbone. The network is trained on various scene text detection datasets with text in English, Korean, Italian, French, Arabic, German and Bangla (Indian).
1823

1924
CRAFT uses a convolutional neural network to produce two outputs, region score, and affinity score. The region score localizes individual characters in the image, and the affinity score groups each character into a single instance. The character-level region awareness mechanism helps in detecting texts of various shapes such as long, curved, and arbitrarily shaped texts.
2025

2126
Getting Started
2227
---------------
23-
Download or clone this repository to your machine and open it in MATLAB.
24-
### Setup
25-
Add path to the source directory.
26-
27-
`addpath('src');`
28-
29-
### Load the pretrained network
30-
Use the below helper to download the pretrained network.
31-
```
32-
model = helper.downloadPretrainedCRAFT;
33-
craftNet = model.craftNet;
34-
```
28+
[detectTextCRAFT](https://in.mathworks.com/help/vision/ref/detecttextcraft.html) - Detect texts in images by using CRAFT deep learning model
3529

36-
Detect Objects Using Pretrained CRAFT
30+
Detect Text Using Pretrained CRAFT
3731
---------------------------------------
38-
32+
Note: This functionality requires Deep Learning Toolbox™ and the Computer Vision Toolbox™ Model for Text Detection. You can install the Computer Vision Toolbox Model for Text Detection from Add-On Explorer. For more information about installing add-ons, see [Get and Manage Add-Ons](https://in.mathworks.com/help/matlab/matlab_env/get-add-ons.html).
3933
```
4034
% Read test image.
4135
orgImg = imread('businessCard.png');
4236
43-
% Pre-process the image
44-
[image, imageScale] = helper.preprocess(orgImg);
45-
46-
% Output from CRAFT network for the given image
47-
out = predict(craftNet,dlarray(image,'SSCB'));
48-
49-
% Postprocess the output
50-
boundingBoxes = helper.postprocess(out,imageScale);
37+
% Perform text detection
38+
bboxes = detectTextCRAFT(orgImg);
5139
5240
% Visualize results
53-
outImg = insertShape(orgImg,'Polygon',boundingBoxes,'LineWidth',5,'Color',"yellow");
41+
outImg = insertShape(I,"rectangle",bboxes,LineWidth=3);
5442
figure; imshow(outImg);
5543
```
5644

5745
<img src="images/business_card.png" alt ="image" width="550" height="350"/>
5846

59-
If the image contains text in arbitrary shape then change the value of `polygonText` variable in `src/+helper/postprocess.m` to `true`.
60-
61-
The CRAFT network has three tunable parameters, text threshold, low text and link threshold. Tune these hyperparameters in `src/+helper/postprocess.m` to get better results.
62-
- Text threshold: Higher value indicates that character in image has to be more clear to be considered as text.
63-
- Low text: Higher value will give less boundary space around characters.
64-
- Link threshold: Higher value will increase the amount by which two characters will be considered as single word.
65-
66-
Code Generation for CRAFT
67-
---------------------------------------
68-
Code generation enables you to generate code and deploy CRAFT on multiple embedded platforms.
69-
70-
Run `codegenCRAFT.m`. This script calls the `craftPredict.m` entry point function and generate CUDA code for it. It will run the generated MEX and gives output.
71-
| Model | Inference Speed (FPS) |
72-
| ------ | ------ |
73-
| CRAFT w/o codegen | 3.044 |
74-
| CRAFT with codegen | 5.356 |
75-
76-
Note: Performance (in FPS) is measured on a TITAN-RTX GPU using 672x992 image.
77-
7847
Text Recognition using OCR + CRAFT
7948
----------------------------------
8049

81-
Output of CRAFT network generates the quadrilateral-shape bounding boxes that can be passed to `ocr` function as region of interest (roi) for text recognition applications.
50+
Output of `detectTextCRAFT` return the bounding boxes that can be passed to `ocr` function as region of interest (roi) for text recognition applications.
8251

8352
```
84-
% Convert boundingBoxes format from [x1 y1 ... x8 y8] to [x y w h].
85-
roi = [];
86-
for i = 1:size(boundingBoxes,1)
87-
w = norm(boundingBoxes(i,[3 4]) - boundingBoxes(i,[1 2]));
88-
h = norm(boundingBoxes(i,[5 6]) - boundingBoxes(i,[3 4]));
89-
roi = [roi; [boundingBoxes(i,1) boundingBoxes(i,2) w h]];
90-
end
91-
9253
% Binarizing the image before using OCR for better results.
9354
I = rgb2gray(orgImg);
9455
BW = imbinarize(I, 'adaptive','ForegroundPolarity','dark','Sensitivity',0.5);
9556
figure; imshow(BW);
9657
9758
% OCR this image using region-of-interest for OCR to avoid processing non-text background.
98-
txt = ocr(BW,roi,'TextLayout','word');
99-
word =[];
100-
idx = [];
101-
for i = 1:size(roi,1)
102-
if ~isempty(txt(i,1).Words)
103-
[~,index] = max(txt(i,1).WordConfidences);
104-
word = [word; txt(i,1).Words(index)];
105-
idx = [idx i];
106-
end
107-
end
108-
Iocr = insertObjectAnnotation(orgImg, 'rectangle',roi(idx,:),word);
59+
txt = ocr(BW,roi,'LayoutAnalysis','word');
60+
61+
% Display the recognized words.
62+
recognizedWords = cat(1,txt(:).Words);
63+
Iocr = insertObjectAnnotation(orgImg, 'rectangle',bboxes,recognizedWords);
10964
figure; imshow(Iocr);
11065
```
11166

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /