how to read numbers using ocr

I want to extract the scorecard from an cricket match and display it,I may be a video or a image,I tried OCR in image ,after cropping the scorecard,but it displayED wrong result,can anyone tell how to process

5 Comments

@Pat: "I tried OCR"?! Do you think that there is any chance to guess what went wrong? We do not know which software and which parameters you used...
If the next dozend of questions does not contain the necessary details also, I'm going to assume, that you are kidding or trolling.
I am not kidding or trolling and i dont want to waste anyones time wen i used ocr the error was many invalid characters was printed in ,
the process which i did is
1)read an image
2)Convert to gray scale
3)Convert to BW
4) Remove all object containing fewer than 15 pixels
5)Compute the number of letters in template file
6)my input file is ANI 77
7)BUT I GET OUTPUT AS ANj 77
8)if my input is 77-0
9)my output IN NOTEPAD IS NOT SAME
NOT RECOGNISING SPECIAL CHARACTERS
@Pat: But you still do not explain, how you get from 6) input to 7) output. Therefore it is absolutely impossible to find out, why there is a problem. Note that you know what "Compute the number of letters in template file" means, but we do not have the faintest idea, and even with very good will, we cannot.
Image this would by my question: "I have a and b and do some ODE calculations. Actually I expect to get 9.773, but I don't. Where is the problem?" Are you able to solve my problem?
It would be much clearer, if you post the code, because this can be reproduced by anybody, whose running MATLAB also.
There are a lot of questions for clarifications to your former questions. It would be respectful and helpful to respond.
my code is as folloes
I find difficult in writing in text pad,which is last line,while writing numbers and special characters,it displat wrong result
foe ex IND 77-4 IT DISPLAY AS IND 7Zm
clc, close all, clear all
% Read image
imagen=imread('samp22.jpg');
% Show image
imagen1 = imagen;
figure,imshow(imagen1);
title('INPUT IMAGE WITH NOISE')
% Convert to gray scale
if size(imagen,3)==3 %RGB image
imagen=rgb2gray(imagen);
end
% Convert to BW
threshold = graythresh(imagen);
imagen =~im2bw(imagen,threshold);
imagen2 = imagen;
figure,imshow(imagen2);
% title('before bwareaopen')
% Remove all object containing fewer than 15 pixels
imagen = bwareaopen(imagen,15);
imagen3 = imagen;
%figure,imshow(imagen3);
%title('after bwareaopen')
%Storage matrix word from image
word=[ ];
re=imagen;
%Opens text.txt as file for write
fid = fopen('text.txt', 'wt');
% Load templates
load templates
global templates
% Compute the number of letters in template file
num_letras=size(templates,2);
while 1
%Fcn 'lines_crop' separate lines in text
[fl re]=lines_crop(re); %fl= first line, re= remaining image
imgn=fl;
n=0;
%Uncomment line below to see lines one by one
%figure,imshow(fl);pause(2)
%-----------------------------------------------------------------
spacevector = []; % to compute the total spaces betweeen
% adjacent letter
rc = fl;
while 1
%Fcn 'letter_crop' separate letters in a line
[fc rc space]=letter_crop(rc); %fc = first letter in the line
%rc = remaining cropped line
%space = space between the letter
% cropped and the next letter
%uncomment below line to see letters one by one
figure,imshow(fc);pause(0.5)
img_r = imresize(fc,[42 24]); %resize letter so that correlation
%can be performed
n = n + 1;
spacevector(n)=space;
%Fcn 'read_letter' correlates the cropped letter with the images
%given in the folder 'letters_numbers'
letter = read_letter(img_r,num_letras);
%letter concatenation
word = [word letter];
if isempty(rc) %breaks loop when there are no more characters
break;
end
end
%-------------------------------------------------------------------
%
max_space = max(spacevector);
no_spaces = 0;
for x= 1:n %loop to introduce space at requisite locations
if spacevector(x+no_spaces)> (0.75 * max_space)
no_spaces = no_spaces + 1;
for m = x:n
word(n+x-m+no_spaces)=word(n+x-m+no_spaces-1);
end
word(x+no_spaces) = ' ';
spacevector = [0 spacevector];
end
end
%fprintf(fid,'%s\n',lower(word));%Write 'word' in text file (lower)
fprintf(fid,'%s\n',word);%Write 'word' in text file (upper)
% Clear 'word' variable
word=[ ];
%*When the sentences finish, breaks the loop
if isempty(re) %See variable 're' in Fcn 'lines'
break
end
end
fclose(fid);
%Open 'text.txt' file
winopen('text.txt')
can u provide template

Answers (0)

This question is closed.

Asked:

Pat
on 19 Sep 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!