📄 main.~pas
字号:
SaveImage.Width := rect_d.Right;
SaveImage.Height:= rect_d.Bottom;
SaveImage.Canvas.CopyRect(rect_d, StretchImage.Canvas, rect_s);
SaveImage.SaveToFile('TempImage.bmp');
// 得到8*8特征值
if EightArrayFeature = nil then
EightArrayFeature := TEightArrayFeature.Create;
// 这里对左边的显示窗口进行操作
EightArrayFeature.SetPicFile('TempImage.bmp');
eight := EightArrayFeature.GetDoubleEightArray;
try
Featureimage.Picture.LoadFromFile('TempImage.bmp');
except
Featureimage.Picture := nil;
end;
showeight(eight);
setmap( eight);
if ImageInputStyle=false then StretchImage.Picture:= nil;
SaveImage.Free;
end;
procedure TRecogForm.showeight(eightmap: TDoubleEightArray);
var
i, j: integer;
begin
for i := 1 to 8 do
for j := 1 to 8 do
if eightmap[i][j]=1 then
eight[i][j].Color := clRed
else
eight[i][j].Color := clwhite;
end;
procedure TRecogForm.setmap(eight: TDoubleEightArray);
begin
EightCode := eight;
end;
procedure TRecogForm.FormDestroy(Sender: TObject);
begin
if FileExists('TempImage.bmp') then
DeleteFile('TempImage.bmp');
//identify.SavetoFile('study.txt');
// identify.Destroy;
end;
procedure TRecogForm.ToolButton2Click(Sender: TObject);
begin
ImageInputStyle:=false;
MouseUpTimer.Enabled:=True;
end;
procedure TRecogForm.ToolButton1Click(Sender: TObject);
var
i:integer;
begin
ImageInputStyle:=True;
MouseUpTimer.Enabled:=False;
StretchImage.Picture:=nil;
if NumberInputOpenPictureDialog.Execute then
begin
StretchImage.picture.LoadFromFile(NumberInputOpenPictureDialog.FileName);
end;
GetFeatureAndRecog(Sender);
end;
procedure TRecogForm.ToolButton4Click(Sender: TObject);
var
s: string;
x: integer;
begin
s := inputbox('更正数据','输入数字0~9','-1'); // 获得更正数据
if s = '-1' then
exit;
try
x := strtoint(s);
except
showmessage('!' + #13 + '该项只能输入数字~' + #13 + '请再次输入。');
exit;
end;
if (x < 0) or (x > 9) then
begin
showmessage('注意!' + #13 + '输入的数字只能在0~9之间。' + #13 + '请再次输入。');
exit
end;
NumberEdit.Text:= inttostr(x);
end;
procedure TRecogForm.Button1Click(Sender: TObject);
var
i:integer;
begin
i:=strtoint(NumberIndexEdit.Text)+1;
NumberIndexEdit.Text:=inttostr(i);
end;
procedure TRecogForm.Button2Click(Sender: TObject);
var
i:integer;
begin
i:=strtoint(NumberIndexEdit.Text)-1;
NumberIndexEdit.Text:=inttostr(i);
end;
procedure TRecogForm.ButtonClick(Sender: TObject);
var
eight1:array[1..8,1..8]of integer;
i,j,k,n,m,NumberID:integer;
filename,SepChar,s,l:String;
f:TextFile;
eight:TDoubleEightArray;
num : array[0..9]of integer;
begin
if SaveDialog1.Execute then
assignfile(f,savedialog1.FileName);
savedialog1.Filter:='*.txt|*.txt';
begin
assignfile(f,savedialog1.FileName);
rewrite(f);
SepChar:=' ';
s:=NumberIndexEdit.Text;
for n:=0 to 9 do
begin
writeln(f,inttostr(n));
num[strtoint(NumberIndexEdit.text)]:= num[strtoint(NumberIndexEdit.text)]+1;
writeln(f,inttostr(num[n]));
begin
for i := 1 to 8 do
for j := 1 to 8 do
begin
if EightCode[j][i]=1 then
eight1[i,j] := 1
else
eight1[i,j] := 0;
NumberID:=strtoint(s);
end;
Writeln(f,s);
for m:=0 to strtoint(s)-1 do
begin
Writeln(f,inttostr(eight1[1,1]),SepChar,inttostr(eight1[1,2]),SepChar,inttostr(eight1[1,3])
,SepChar,inttostr(eight1[1,4]),SepChar,inttostr(eight1[1,5]),SepChar,inttostr(eight1[1,6]),SepChar,inttostr(eight1[1,7])
,SepChar,inttostr(eight1[1,8]));
Writeln(f,inttostr(eight1[2,1]),SepChar,inttostr(eight1[2,2]),SepChar,inttostr(eight1[2,3])
,SepChar,inttostr(eight1[2,4]),SepChar,inttostr(eight1[2,5]),SepChar,inttostr(eight1[2,6])
,SepChar,inttostr(eight1[2,7]),SepChar,inttostr(eight1[2,8]));
Writeln(f,inttostr(eight1[3,1]),SepChar,inttostr(eight1[3,2]),SepChar,inttostr(eight1[3,3])
,SepChar,inttostr(eight1[3,4]),SepChar,inttostr(eight1[3,5]),SepChar,inttostr(eight1[3,6])
,SepChar,inttostr(eight1[3,7]),SepChar,inttostr(eight1[3,8]));
Writeln(f,inttostr(eight1[4,1]),SepChar,inttostr(eight1[4,2]),SepChar,inttostr(eight1[4,3])
,SepChar,inttostr(eight1[4,4]),SepChar,inttostr(eight1[4,5]),SepChar,inttostr(eight1[4,6])
,SepChar,inttostr(eight1[4,7]),SepChar,inttostr(eight1[4,8]));
Writeln(f,inttostr(eight1[5,1]),SepChar,inttostr(eight1[5,2]),SepChar,inttostr(eight1[5,3])
,SepChar,inttostr(eight1[5,4]),SepChar,inttostr(eight1[5,5]),SepChar,inttostr(eight1[5,6])
,SepChar,inttostr(eight1[5,7]),SepChar,inttostr(eight1[5,8]));
Writeln(f,inttostr(eight1[6,1]),SepChar,inttostr(eight1[6,2]),SepChar,inttostr(eight1[6,3])
,SepChar,inttostr(eight1[6,4]),SepChar,inttostr(eight1[6,5]),SepChar,inttostr(eight1[6,6])
,SepChar,inttostr(eight1[6,7]),SepChar,inttostr(eight1[6,8]));
Writeln(f,inttostr(eight1[7,1]),SepChar,inttostr(eight1[7,2]),SepChar,inttostr(eight1[7,3])
,SepChar,inttostr(eight1[7,4]),SepChar,inttostr(eight1[7,5]),SepChar,inttostr(eight1[7,6])
,SepChar,inttostr(eight1[7,7]),SepChar,inttostr(eight1[7,8]));
Writeln(f,inttostr(eight1[8,1]),SepChar,inttostr(eight1[8,2]),SepChar,inttostr(eight1[8,3])
,SepChar,inttostr(eight1[8,4]),SepChar,inttostr(eight1[8,5]),SepChar,inttostr(eight1[8,6])
,SepChar,inttostr(eight1[8,7]),SepChar,inttostr(eight1[8,8]));
end;
end;
end;
end;
CloseFile(f);
end;
////////////////////////////////////////////////////////////////
procedure TRecogForm.CheckBox5Click(Sender: TObject);
var
i,j,k,l:integer;
begin
if CheckBox5.Checked=true then
begin
for i:=1 to 8 do
for j:=1 to 8 do
begin
for k:=1 to 9 do
for l:=1 to 9 do
begin
PatternDisplayImage5.Canvas.Pixels[9*i+k,9*j+l]:=RGB(0,0,0);
if EightCode[i][j]=0 then
PatternDisplayImage5.Canvas.Pixels[9*i+k,9*j+l]:=Clwhite;
end;
end;
end;
end;
procedure TRecogForm.CheckBox2Click(Sender: TObject);
var
i,j,k,l:integer;
begin
if CheckBox2.Checked=true then
begin
for i:=1 to 8 do
for j:=1 to 8 do
begin
for k:=1 to 9 do
for l:=1 to 9 do
begin
PatternDisplayImage2.Canvas.Pixels[9*i+k,9*j+l]:=RGB(0,0,0);
if EightCode[i][j]=0 then
PatternDisplayImage2.Canvas.Pixels[9*i+k,9*j+l]:=Clwhite;
end;
end;
end;
end;
procedure TRecogForm.CheckBox4Click(Sender: TObject);
var
i,j,k,l:integer;
begin
if CheckBox4.Checked=true then
begin
for i:=1 to 8 do
for j:=1 to 8 do
begin
for k:=1 to 9 do
for l:=1 to 9 do
begin
PatternDisplayImage4.Canvas.Pixels[9*i+k,9*j+l]:=RGB(0,0,0);
if EightCode[i][j]=0 then
PatternDisplayImage4.Canvas.Pixels[9*i+k,9*j+l]:=Clwhite;
end;
end;
end;
end;
procedure TRecogForm.CheckBox3Click(Sender: TObject);
var
i,j,k,l:integer;
begin
if CheckBox3.Checked=true then
begin
for i:=1 to 8 do
for j:=1 to 8 do
begin
for k:=1 to 9 do
for l:=1 to 9 do
begin
PatternDisplayImage3.Canvas.Pixels[9*i+k,9*j+l]:=RGB(0,0,0);
if EightCode[i][j]=0 then
PatternDisplayImage3.Canvas.Pixels[9*i+k,9*j+l]:=Clwhite;
end;
end;
end;
end;
procedure TRecogForm.CheckBox10Click(Sender: TObject);
var
i,j,k,l:integer;
begin
if CheckBox10.Checked=true then
begin
for i:=1 to 8 do
for j:=1 to 8 do
begin
for k:=1 to 9 do
for l:=1 to 9 do
begin
PatternDisplayImage10.Canvas.Pixels[9*i+k,9*j+l]:=RGB(0,0,0);
if EightCode[i][j]=0 then
PatternDisplayImage10.Canvas.Pixels[9*i+k,9*j+l]:=Clwhite;
end;
end;
end;
end;
procedure TRecogForm.CheckBox9Click(Sender: TObject);
var
i,j,k,l:integer;
begin
if CheckBox9.Checked=true then
begin
for i:=1 to 8 do
for j:=1 to 8 do
begin
for k:=1 to 9 do
for l:=1 to 9 do
begin
PatternDisplayImage9.Canvas.Pixels[9*i+k,9*j+l]:=RGB(0,0,0);
if EightCode[i][j]=0 then
PatternDisplayImage9.Canvas.Pixels[9*i+k,9*j+l]:=Clwhite;
end;
end;
end;
end;
procedure TRecogForm.CheckBox8Click(Sender: TObject);
var
i,j,k,l:integer;
begin
if CheckBox8.Checked=true then
begin
for i:=1 to 8 do
for j:=1 to 8 do
begin
for k:=1 to 9 do
for l:=1 to 9 do
begin
PatternDisplayImage8.Canvas.Pixels[9*i+k,9*j+l]:=RGB(0,0,0);
if EightCode[i][j]=0 then
PatternDisplayImage8.Canvas.Pixels[9*i+k,9*j+l]:=Clwhite;
end;
end;
end;
end;
procedure TRecogForm.CheckBox7Click(Sender: TObject);
var
i,j,k,l:integer;
begin
for i:=1 to 8 do
for j:=1 to 8 do
begin
for k:=1 to 9 do
for l:=1 to 9 do
begin
PatternDisplayImage7.Canvas.Pixels[9*i+k,9*j+l]:=RGB(0,0,0);
if EightCode[i][j]=0 then
PatternDisplayImage7.Canvas.Pixels[9*i+k,9*j+l]:=Clwhite;
end;
end;
end;
procedure TRecogForm.CheckBox6Click(Sender: TObject);
var
i,j,k,l:integer;
begin
if CheckBox6.Checked=true then
begin
for i:=1 to 8 do
for j:=1 to 8 do
begin
for k:=1 to 9 do
for l:=1 to 9 do
begin
PatternDisplayImage6.Canvas.Pixels[9*i+k,9*j+l]:=RGB(0,0,0);
if EightCode[i][j]=0 then
PatternDisplayImage6.Canvas.Pixels[9*i+k,9*j+l]:=Clwhite;
end;
end;
end;
end;
///////////////////////////////////////////////////////////////////////////
procedure TRecogForm.Button4Click(Sender: TObject);
var
i,j,m,n,amout,t,k:Integer;
Number,Total,FeatureCode:integer;
MyLine,sNumber,sTotal,sFeatureCode,SepChar: string;
item: array [1..8] of string;
f:TextFile;
begin
Try
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -