Skip to content

Commit 97fd02f

Browse files
committed
Added the ThreadedOCR demo for FMX
Fixed issue with the OBS Virtual Camera in SimpleOCR
1 parent d8b4edd commit 97fd02f

File tree

9 files changed

+2151
-6
lines changed

9 files changed

+2151
-6
lines changed

demos/Delphi_FMX_Windows/SimpleOCR/uMainForm.pas

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,20 @@ procedure TMainForm.FormCreate(Sender: TObject);
8989

9090
FBitmap := TBitmap.Create;
9191

92-
FVideoCap := TCaptureDeviceManager.Current.DefaultVideoCaptureDevice;
93-
if assigned(FVideoCap) then
92+
if assigned(TCaptureDeviceManager.Current) and (TCaptureDeviceManager.Current.Count > 0) then
9493
begin
95-
FVideoCap.OnSampleBufferReady := VideoCap_OnSampleBufferReady;
96-
FVideoCap.Quality := TVideoCaptureQuality.PhotoQuality;
97-
end;
94+
FVideoCap := TCaptureDeviceManager.Current.DefaultVideoCaptureDevice;
95+
96+
if assigned(FVideoCap) and (FVideoCap.Name <> 'OBS Virtual Camera') then
97+
begin
98+
FVideoCap.OnSampleBufferReady := VideoCap_OnSampleBufferReady;
99+
FVideoCap.Quality := TVideoCaptureQuality.PhotoQuality;
100+
end
101+
else
102+
FVideoCap := nil;
103+
end
104+
else
105+
FVideoCap := nil;
98106

99107
if not(TesseractOCR1.Initialize('org.sw.demo.danbloomberg.leptonica-1.86.0.dll',
100108
'google.tesseract.libtesseract-main.dll',
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
del /s /q *.dcu
2+
del /s /q *.exe
3+
del /s /q *.rsm
4+
del /s /q *.log
5+
del /s /q *.dsk
6+
del /s /q *.identcache
7+
del /s /q *.stat
8+
del /s /q *.local
9+
del /s /q *.~*
10+
rmdir Win32\Debug
11+
rmdir Win32\Release
12+
rmdir Win32
13+
rmdir Win64\Debug
14+
rmdir Win64\Release
15+
rmdir Win64
16+
rmdir __history
17+
rmdir __recovery
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
program ThreadedOCR;
2+
3+
uses
4+
System.StartUpCopy,
5+
FMX.Forms,
6+
uMainForm in 'uMainForm.pas' {MainForm},
7+
uOCRWorkerThread in 'uOCRWorkerThread.pas';
8+
9+
{$R *.res}
10+
11+
begin
12+
Application.Initialize;
13+
Application.CreateForm(TMainForm, MainForm);
14+
Application.Run;
15+
end.

demos/Delphi_FMX_Windows/ThreadedOCR/ThreadedOCR.dproj

Lines changed: 1310 additions & 0 deletions
Large diffs are not rendered by default.
151 KB
Binary file not shown.
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
object MainForm: TMainForm
2+
Left = 0
3+
Top = 0
4+
Caption = 'Simple OCR'
5+
ClientHeight = 664
6+
ClientWidth = 1065
7+
FormFactor.Width = 320
8+
FormFactor.Height = 480
9+
FormFactor.Devices = [Desktop]
10+
OnCreate = FormCreate
11+
OnClose = FormClose
12+
OnShow = FormShow
13+
DesignerMasterStyle = 0
14+
object ToolBar1: TToolBar
15+
Padding.Left = 8.000000000000000000
16+
Padding.Top = 8.000000000000000000
17+
Padding.Right = 8.000000000000000000
18+
Padding.Bottom = 8.000000000000000000
19+
Size.Width = 1065.000000000000000000
20+
Size.Height = 40.000000000000000000
21+
Size.PlatformDefault = False
22+
TabOrder = 0
23+
object OpenSampleBtn: TButton
24+
Align = Left
25+
Margins.Right = 8.000000000000000000
26+
Position.X = 8.000000000000000000
27+
Position.Y = 8.000000000000000000
28+
Size.Width = 120.000000000000000000
29+
Size.Height = 24.000000000000000000
30+
Size.PlatformDefault = False
31+
TabOrder = 0
32+
Text = 'Open Sample'
33+
OnClick = OpenSampleBtnClick
34+
end
35+
object OpenBtn: TButton
36+
Align = Left
37+
Margins.Right = 8.000000000000000000
38+
Position.X = 136.000000000000000000
39+
Position.Y = 8.000000000000000000
40+
Size.Width = 120.000000000000000000
41+
Size.Height = 24.000000000000000000
42+
Size.PlatformDefault = False
43+
TabOrder = 2
44+
Text = 'Open image ...'
45+
OnClick = OpenBtnClick
46+
end
47+
object RecognizeBtn: TButton
48+
Align = Left
49+
Margins.Right = 8.000000000000000000
50+
Position.X = 392.000000000000000000
51+
Position.Y = 8.000000000000000000
52+
Size.Width = 120.000000000000000000
53+
Size.Height = 24.000000000000000000
54+
Size.PlatformDefault = False
55+
TabOrder = 3
56+
Text = 'Recognize'
57+
OnClick = RecognizeBtnClick
58+
end
59+
object Layout3: TLayout
60+
Align = Client
61+
Padding.Left = 16.000000000000000000
62+
Size.Width = 537.000000000000000000
63+
Size.Height = 24.000000000000000000
64+
Size.PlatformDefault = False
65+
TabOrder = 4
66+
object Label1: TLabel
67+
Align = Left
68+
Position.X = 16.000000000000000000
69+
Size.Width = 41.000000000000000000
70+
Size.Height = 24.000000000000000000
71+
Size.PlatformDefault = False
72+
Text = 'Mode'
73+
TabOrder = 0
74+
end
75+
object ModeCb: TComboBox
76+
Align = Client
77+
Items.Strings = (
78+
'Orientation and script detection only'
79+
80+
'Automatic page segmentation with orientation and script detectio' +
81+
'n'
82+
'Automatic page segmentation, but no OSD, or OCR'
83+
'Fully automatic page segmentation, but no OSD'
84+
'Assume a single column of text of variable sizes'
85+
'Assume a single uniform block of vertically aligned text'
86+
'Assume a single uniform block of text'
87+
'Treat the image as a single text line'
88+
'Treat the image as a single word'
89+
'Treat the image as a single word in a circle'
90+
'Treat the image as a single character'
91+
'Find as much text as possible in no particular order'
92+
'Sparse text with orientation and script det.'
93+
'Treat the image as a single text line, Tesseract-specific')
94+
ItemIndex = 0
95+
Size.Width = 480.000000000000000000
96+
Size.Height = 24.000000000000000000
97+
Size.PlatformDefault = False
98+
TabOrder = 1
99+
end
100+
end
101+
object CopyVideoFrameBtn: TButton
102+
Align = Left
103+
Enabled = False
104+
Margins.Right = 8.000000000000000000
105+
Position.X = 264.000000000000000000
106+
Position.Y = 8.000000000000000000
107+
Size.Width = 120.000000000000000000
108+
Size.Height = 24.000000000000000000
109+
Size.PlatformDefault = False
110+
TabOrder = 1
111+
Text = 'Copy video frame'
112+
OnClick = CopyVideoFrameBtnClick
113+
end
114+
end
115+
object Layout1: TLayout
116+
Align = Client
117+
Size.Width = 762.000000000000000000
118+
Size.Height = 602.000000000000000000
119+
Size.PlatformDefault = False
120+
TabOrder = 1
121+
object Image1: TImage
122+
MultiResBitmap = <
123+
item
124+
end>
125+
Align = Client
126+
Size.Width = 762.000000000000000000
127+
Size.Height = 602.000000000000000000
128+
Size.PlatformDefault = False
129+
end
130+
end
131+
object Splitter1: TSplitter
132+
Align = Right
133+
Cursor = crHSplit
134+
MinSize = 20.000000000000000000
135+
Position.X = 762.000000000000000000
136+
Position.Y = 40.000000000000000000
137+
Size.Width = 8.000000000000000000
138+
Size.Height = 602.000000000000000000
139+
Size.PlatformDefault = False
140+
end
141+
object OpenDialog1: TOpenDialog
142+
Left = 488
143+
Top = 320
144+
end
145+
object TabControl1: TTabControl
146+
Align = Right
147+
Position.X = 770.000000000000000000
148+
Position.Y = 40.000000000000000000
149+
Size.Width = 295.000000000000000000
150+
Size.Height = 602.000000000000000000
151+
Size.PlatformDefault = False
152+
TabIndex = 0
153+
TabOrder = 4
154+
TabPosition = PlatformDefault
155+
Sizes = (
156+
295s
157+
576s)
158+
object TextTabItem: TTabItem
159+
CustomIcon = <
160+
item
161+
end>
162+
IsSelected = True
163+
Size.Width = 74.000000000000000000
164+
Size.Height = 26.000000000000000000
165+
Size.PlatformDefault = False
166+
StyleLookup = ''
167+
TabOrder = 0
168+
Text = 'Text result'
169+
ExplicitSize.cx = 74.000000000000000000
170+
ExplicitSize.cy = 26.000000000000000000
171+
object Memo1: TMemo
172+
Touch.InteractiveGestures = [Pan, LongTap, DoubleTap]
173+
DataDetectorTypes = []
174+
ReadOnly = True
175+
Align = Client
176+
Size.Width = 295.000000000000000000
177+
Size.Height = 576.000000000000000000
178+
Size.PlatformDefault = False
179+
TabOrder = 0
180+
Viewport.Width = 291.000000000000000000
181+
Viewport.Height = 572.000000000000000000
182+
end
183+
end
184+
end
185+
object StatusBar1: TStatusBar
186+
Position.Y = 642.000000000000000000
187+
ShowSizeGrip = True
188+
Size.Width = 1065.000000000000000000
189+
Size.Height = 22.000000000000000000
190+
Size.PlatformDefault = False
191+
TabOrder = 5
192+
object StatusLbl: TLabel
193+
Align = Left
194+
AutoSize = True
195+
Size.Width = 0.000000000000000000
196+
Size.Height = 22.000000000000000000
197+
Size.PlatformDefault = False
198+
TabOrder = 0
199+
end
200+
end
201+
end

0 commit comments

Comments
 (0)