Another look at ASPRISEOCR-OCR application development
I write this blog time for 2015/11/24 days, pay attention to time because many articles on the internet very long time, some have been unable to reference the
Many people want to find the relevant technical articles on the Internet when they recognize text or digital 0~9 a~z from images.
I also looked for a lot, but unfortunately I didn't find much valuable information.
Most of the information is old and there's a lot about ASPRISEOCR.
Especially with regard to Delphi + ASPRISEOCR Less
I found the aspriseocr cracked files from the Internet, and have been packaged in my upload materials, you can download aspriseocr-crake.zip
My development environment is DELPHI7 +WIN8 64-bit
There are several points to note in this application
1. The image identified can only be black on white, other types of pictures are not correct
2. AspriseOCR.dll, DevIL.dll, ILU.dll
Three files placed in the same directory as the app you developed
3. Call the DLL function defined as
function OCR (imgname:string;imagetype:integer):P Char;stdcall;
External ' AspriseOCR.dll ';
function OCR (imgname:pchar;i:integer):P char;stdcall;external ' AspriseOCR.dll ';
function Ocrbarcodes (imgname:string;imagetype:integer):P Char;stdcall;
External ' AspriseOCR.dll ';
Function Ocrpart (filename:string; imagetype:integer; startx:integer;
Starty:integer; Width:integer; Height:integer):P Char;stdcall;
External ' AspriseOCR.dll ';
Take a look at the definition of the first function above the OCR parameter Imagname String or Pchar which is correct?
I can tell you all are compiled and passed, and both of these definitions are right.
So many things need to be verified by themselves
-----------------------
Image processing for recognition
My graph column
2 value of the picture-the practice of most people on the Internet
function Tfrmmain.cbmptwovalues (bmp:tbitmap;graythreshold:byte): Tbitmap;
Var
P:pbytearray;
Gray, X, Y:integer;
Abmp:tbitmap;
Begin
Abmp:=tbitmap.create;
Abmp.assign (IMAGE1.PICTURE.BITMAP);
Abmp:=bmp;
Set to 24-bit true Color
Abmp.pixelformat: = Pf24bit;
Randomize
For y: = 0 to Abmp.height-1 do
Begin
P: = Abmp.scanline[y];
For x: = 0 to Abmp.width-1 do
Begin
Three bytes of one pixel point
Y = 0.299 * R + 0.587 * G + 0.114 * B
Gray: = Round (p[x * 3 + 2] * 0.3 + p[x * 3 + 1] * 0.59 +
P[X * 3] * 0.11);
If Gray > Graythreshold then//Global threshold 128
Begin
P[x * 3]: = 255;
P[X * 3 + 1]: = 255;
P[X * 3 + 2]: = 255;
End
Else
Begin
P[x * 3]: = 0;
P[X * 3 + 1]: = 0;
P[X * 3 + 2]: = 0;
End
End
End
Image2.Picture.Bitmap.Assign (BMP);
Result:=abmp;
End
2 value of the picture-my own approach (for my particular image)
function Tfrmmain.cbmpblackwhiteexe (abmp:tbitmap;amaincolor:tcolor;amaintorl:byte): Tbitmap;
Var
Bm:tbitmap;
Bx,by:integer;
Acolor:tcolor;
Aclr,aclg,aclb:byte;
Achagecoloren:boolean;
Begin
Bm:=tbitmap.create;
Bm:=abmp;
For BX: = 0 to BM. Width-1 do
Begin
For by: = 0 to BM. Height-1 do
Begin
Clblue = TColor ($FF 0000); Clblack = TColor ($000000);
clred = TColor ($0000ff); clwhite = TColor ($FFFFFF);
Cllime = TColor ($00FF00);
ACOLOR:=BM. Canvas.pixels[bx,by];
Achagecoloren:=false;
Aclb:=abs (Byte (Acolor shr)-byte (Amaincolor shr 16));
If Aclb<=amaintorl Then
Begin
Blue OK
Aclg:=abs (Byte (acolor shr 8)-byte (Amaincolor shr 8));
If ACLG <= Amaintorl Then
Begin
Green OK
Aclr:=abs (Byte (Acolor)-byte (Amaincolor));
If ACLR <= Amaintorl Then
Begin
Red OK
Achagecoloren:=true;
End
End
End
If Achagecoloren Then
Bm. Canvas.pixels[bx,by]:=tcolor ($FFFFFF); White
Else
Bm. Canvas.pixels[bx,by]:=tcolor ($000000); Black
End
End
RESULT:=BM;
End
Picture Inverse color
Procedure Tfrmmain.negative (var bmp:tbitmap);
Var
I, J:integer;
Prgb:prgbtriple;
Begin
Bmp.pixelformat:=pf24bit;
For I: = 0 to Bmp.height-1 do
Begin
Prgb: = Bmp.scanline[i];
For J: = 0 to Bmp.width-1 do
Begin
prgb^.rgbtred: =not prgb^.rgbtred;
Prgb^.rgbtgreen: =not prgb^.rgbtgreen;
Prgb^.rgbtblue: =not prgb^.rgbtblue;
INC (PRGB);
End
End
End
The above only for the reference of everyone
It's not good, don't squirt me.
Look again ASPRISEOCR-OCR application development-20151124