matlab-deep-learning / Seven-Segment-Digit-Recognition

Seven Segment Digit Recognition in MATLAB
https://www.mathworks.com/products/deep-learning.html
Other
6 stars 0 forks source link
computer-vision deep-learning industrial-automation matlab matlab-deep-learning ocr ocr-recognition pretrained-models seven-segment seven-segments-display text-detection text-detection-recognition

Seven Segment Digit Recognition

This repository implements seven segment digit recognition in MATLAB®.

Open in MATLAB Online

Creator: MathWorks Development

Requirements


Note: Previous MATLAB release users can use this branch to download the pretrained models.

Overview

This repository implements seven segment digit recognition using two steps. The first step detects the location of image text using detectTextCRAFT function that requires Deep Learning Toolbox™ and Computer Vision Toolbox™ Model for Text Detection. The second stage uses the OCR function from the Computer Vision Toolbox™ to recognize the digits.

The two-step approach helps improve OCR by only processing image regions that contains text. This is useful in industrial automation applications where the digital displays are often surrounded by other objects and background content that can hinder the performance of OCR.

Recognize Seven Segment Digits

% Read image.
  orgImg = imread('sevenSeg.png');

% Detect seven segment digits.
  bboxes = detectTextCRAFT(orgImg);

% Binarizing the image before using OCR for better results.
  I = rgb2gray(orgImg);
  BW = imbinarize(I, 'adaptive');
  BW = ~BW;

% Recognize seven segment digit using ocr.
  output = ocr(BW,bboxes,Model="seven-segment");

% Display results.
  recognizedWords = cat(1,output(:).Words);
  Iocr = insertObjectAnnotation(orgImg, 'rectangle',bboxes,recognizedWords);
  figure; imshow(Iocr);
image

Note: To improve OCR results, see Troubleshoot ocr Function Results.

References

[1] Baek, Y., Lee, B., Han, D., Yun, S. and Lee, H., 2019. Character region awareness for text detection. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (pp. 9365-9374).

Copyright 2021-2024 The MathWorks, Inc.