using OCR on a custom, discontinuous font
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I need help using an OCR to extract numbers from a video. I have a few video files, each goes over an hour, that recorded pressure. I am trying to extract data (4 digit numbers) from these videos by 1) extract certain number of frames and save them as png files, and 2) use OCR to read values off from each of the png file. A sample picture is shown below. This collage image contains 71 frames. I tried using 'ocrTrainer' with over 50 frames but I couldn't make Matlab read any values from the images. The non-continuous shape of the font also makes it hard to use ocrTrainer. Matlab recognized each of the digitized lines that form numbers as separate numbers and required a lot of manual manipulation to correctly define ROI. Hence, using a large number of frames for training becomes a challenge. I am wondering if there's an easy way to use ocrTrainer or if Matlab can import/use the type of font that resemble this. So far I was not able to identify any default font that looks like this.
Thank you in advance for your comments!
0 commentaires
Réponses (2)
yanqi liu
le 1 Fév 2021
use cnn to make self ocr
clc; clear all; close all;
x = imread('ceshi.png');
y = rgb2hsv(x);
v = mat2gray(y(:,:,3));
bw = im2bw(v, 0.7);
bw2 = bwareaopen(bw, 100);
bw3 = bwareafilt(bw2, 1);
bw2(bw3) = 0;
bw2 = imclose(bw2, strel('line', 10, 90));
sz = size(bw2);
bw3 = imclose(bw2, strel('line', round(sz(2)*0.5), 0));
[L, num] = bwlabel(bw3);
stats = regionprops(L);
figure; imshow(x);
for i = 1 : length(stats)
rect = round(stats(i).BoundingBox);
bwt = bw2;
bwt(L~=i) = 0;
stats2 = regionprops(bwt);
for j = 1:length(stats2)
rect2 = round(stats2(j).BoundingBox);
bwt2 = imcrop(bwt, rect2);
hold on; rectangle('Position', rect2, 'EdgeColor', 'c', 'LineWidth', 2);
end
end
0 commentaires
Voir également
Catégories
En savoir plus sur Convert Image Type dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!