Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

MBS FileMaker Plugin Example Databases

OCR

All examples are included with download of MBS FileMaker Plugin.

OCR.fmp12

Overview
Tables 1
Relationships 0
Layouts 1
Scripts 7
Value Lists 0
Custom Functions 0
Custom Menus 33
File Options
Default custom menu set [Standard FileMaker Menus]
Default theme Apex Blue
When opening file
Minimum allowed version 12.0
Login using Account Name; Account= Admin
Allow user to save password On
Require iOS passcode Off
Show Sign-in fields Off
Switch to layout Off
Hide all toolbars Off
Script triggers
OnFirstWindowOpen Off
OnLastWindowClose Off
OnWindowOpen Off
OnWindowClose Off
OnFileAVPlayerChange Off
OnWindowTransaction Off
Thumbnail Settings
Generate Thumbnails On; Temporary

 

Tables

Table Name
Statistics
Occurrences in Relationship Graph
OCR
3 fields defined, 2 records
OCR

Fields

Table Name: OCR - 3 Fields
Field Name Type Options Comments On Layouts In Relationships In Scripts In Value Lists
Image Normal, Binary Auto-Enter:
  • Allow editing
Validation:
  • Only during data entry
Storage:
  • Repetitions: 1
      Result Normal, Text Auto-Enter:
      • Allow editing
      Validation:
      • Only during data entry
      Storage:
      • Repetitions: 1
      • Indexing: None
      • Automatically create indexes as needed
      • Index Language: German
          Text Normal, Text Auto-Enter:
          • Allow editing
          Validation:
          • Only during data entry
          Storage:
          • Repetitions: 1
          • Indexing: None
          • Automatically create indexes as needed
          • Index Language: German

              Layout Objects: OCR

              Regular Fields

              Field Name: OCR::Image
              Field Properties Coordinates Field Format Field Behavior Quick Find
              • Top: 24 pt
              • Left: 138 pt
              • Bottom: 149 pt
              • Right: 391 pt
              • Anchoring: Left, Top
              Field Format:
              • Edit Box
              Field Behavior:
              • Allow field to be entered: In Find mode, In Browse mode
              • Touch keyboard type: System Default
              • Go to next field using: Tab key
              No

              Field Name: OCR::Result
              Field Properties Coordinates Field Format Field Behavior Quick Find
              • Top: 150 pt
              • Left: 138 pt
              • Bottom: 170 pt
              • Right: 391 pt
              • Anchoring: Left, Top
              Field Format:
              • Edit Box
              Field Behavior:
              • Allow field to be entered: In Find mode, In Browse mode
              • Touch keyboard type: System Default
              • Go to next field using: Tab key
              Yes

              Field Name: OCR::Text
              Field Properties Coordinates Field Format Field Behavior Quick Find
              • Top: 174 pt
              • Left: 138 pt
              • Bottom: 254 pt
              • Right: 391 pt
              • Anchoring: Left, Top
              Field Format:
              • Edit Box
              Field Behavior:
              • Allow field to be entered: In Find mode, In Browse mode
              • Touch keyboard type: System Default
              • Go to next field using: Tab key
              Yes

              Buttons

              Button Properties Coordinates Script/Script Step
                Type:
              • Text: Run OCR
              • Top: 24 pt
              • Left: 399 pt
              • Bottom: 53 pt
              • Right: 526 pt
              • Anchoring: Left, Top
              Perform Script [ “Run” ]

              Scripts:


              Script Hierarchy

              Run
              Trace
              Load Tesseract 4
              Load Tesseract 5
              Run Tesseract 4 or 5.x
              Show Version
              Clear

              Next Script: [Trace]
              Script Name Run
              Run script with full access privileges Off
              Siri Shortcut Visible Off
              Include In Menu Yes
              Layouts that use this script
              Scripts that use this script
                Script Definition
                Script Steps
                • If [ MBS("OCR.IsLoaded") ]
                • #use newer version if initialized
                • Perform Script [ “Run Tesseract 4 or 5.x” ]
                • Exit Script [ Result: Get(ScriptResult) ]
                • End If
                • #data folder in examples folder
                • Set Variable [ $databasePath; Value:Get(FilePath) ]
                • Set Variable [ $databasePath; Value:MBS("Path.FilemakerPathToNativePath"; $databasePath) ]
                • Set Variable [ $databasePath; Value:Substitute ( $databasePath ; ".fp7" ; ".fmp12") ]
                • Set Variable [ $databaseName; Value:Get(FileName) & ".fmp12" ]
                • Set Variable [ $path; Value:Substitute ( $databasePath ; $databaseName ; "" ) ]
                • #Init OCR
                • Set Variable [ $r; Value:MBS( "OCR.Initialize"; $path; "eng") ]
                • Set Field [ OCR::Result; $r ]
                • If [ MBS("isError") ≠ 0 ]
                • Exit Script [ Result: $r ]
                • End If
                • Set Variable [ $rr; Value:MBS( "OCR.SetPageSegMode"; "Auto") ]
                • #Process Image
                • Set Variable [ $img; Value:MBS("GMImage.NewFromContainer"; OCR::Image) ]
                • Set Variable [ $r; Value:MBS( "OCR.SetImage"; $img) ]
                • Set Field [ OCR::Text; MBS("OCR.GetTExt") ]
                • #Cleanup
                • Set Variable [ $r; Value:MBS( "OCR.CleanUp") ]
                • Set Variable [ $r; Value:MBS( "GMImage.Destroy"; $img) ]
                Fields used in this script
                Scripts used in this script
                Layouts used in this script
                  Tables used in this script
                  Table occurrences used by this script
                  Custom Functions used by this script
                    Custom menu set used by this script

                      Previous Script: [Run] Next Script: [Load Tesseract 4]
                      Script Name Trace
                      Run script with full access privileges Off
                      Siri Shortcut Visible Off
                      Include In Menu Yes
                      Layouts that use this script
                        Scripts that use this script
                          Script Definition
                          Script Steps
                          • Set Variable [ $Trace; Value:MBS("Trace") ]
                          Fields used in this script
                            Scripts used in this script
                              Layouts used in this script
                                Tables used in this script
                                  Table occurrences used by this script
                                    Custom Functions used by this script
                                      Custom menu set used by this script

                                        Previous Script: [Trace] Next Script: [Load Tesseract 5]
                                        Script Name Load Tesseract 4
                                        Run script with full access privileges Off
                                        Siri Shortcut Visible Off
                                        Include In Menu Yes
                                        Layouts that use this script
                                          Scripts that use this script
                                            Script Definition
                                            Script Steps
                                            • If [ MBS( "OCR.IsLoaded" ) = 0 ]
                                            • If [ MBS("isMacOS") ]
                                            • If [ MBS("Files.FileExists"; "/usr/local/lib/libtesseract.dylib") ]
                                            • #load from homebrew
                                            • Set Variable [ $r; Value:MBS( "OCR.Load"; "/usr/local/lib/liblept.5.dylib" ) ]
                                            • Set Variable [ $r; Value:MBS( "OCR.Load"; "/usr/local/lib/libtesseract.dylib" ) ]
                                            • Else
                                            • #load the copy from MBS website
                                            • Set Variable [ $r; Value:MBS( "OCR.Load"; "/Users/cs/Tesseract/tesseract4/tesseract.dylib" ) ]
                                            • End If
                                            • Else If [ MBS("isWindows") ]
                                            • Set Variable [ $r; Value:MBS("Process.SetCurrentDirectory"; "C:\Program Files\Tesseract-OCR") & MBS( "OCR.Load"; "liblept-5.dll" ) & MBS( "OCR.Load"; "libtesseract-4.dll" ) ]
                                            • Else If [ MBS("isLinux") ]
                                            • Set Variable [ $r; Value:MBS( "OCR.Load"; "liblept.so.5" ) & MBS( "OCR.Load"; "libtesseract.so.4" ) ]
                                            • Else
                                            • Set Variable [ $r; Value:"New platform?" ]
                                            • End If
                                            • Show Custom Dialog [ Title: "OCR Loaded"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                            • End If
                                            Fields used in this script
                                              Scripts used in this script
                                                Layouts used in this script
                                                  Tables used in this script
                                                    Table occurrences used by this script
                                                      Custom Functions used by this script
                                                        Custom menu set used by this script

                                                          Previous Script: [Load Tesseract 4] Next Script: [Run Tesseract 4 or 5.x]
                                                          Script Name Load Tesseract 5
                                                          Run script with full access privileges Off
                                                          Siri Shortcut Visible Off
                                                          Include In Menu Yes
                                                          Layouts that use this script
                                                            Scripts that use this script
                                                              Script Definition
                                                              Script Steps
                                                              • If [ MBS( "OCR.IsLoaded" ) = 0 ]
                                                              • If [ MBS("isMacOS") ]
                                                              • #load from homebrew installation
                                                              • Set Variable [ $r; Value:MBS( "OCR.Load"; "/usr/local/Cellar/leptonica/1.82.0/lib/liblept.5.dylib" ) ]
                                                              • Set Variable [ $r; Value:MBS( "OCR.Load"; "/usr/local/Cellar/tesseract/5.1.0/lib/libtesseract.5.dylib" ) ]
                                                              • Else If [ MBS("isWindows") ]
                                                              • #download e.g. on https://github.com/UB-Mannheim/tesseract/wiki
                                                              • Set Variable [ $r; Value:// DLL names may change with new version. Used to be "liblept-5.dll", but now "libleptonica-6.dll" MBS("Process.SetCurrentDirectory"; "C:\Program Files\Tesseract-OCR") & MBS( "OCR.Load"; "libleptonica-6.dll" ) & MBS( "OCR.Load"; "libtesseract-5.dll" ) ]
                                                              • Else If [ MBS("isLinux") ]
                                                              • #install via package manager
                                                              • Set Variable [ $r; Value:MBS( "OCR.Load"; "liblept.so.5" ) & MBS( "OCR.Load"; "libtesseract.so.5" ) ]
                                                              • Else
                                                              • Set Variable [ $r; Value:"New platform?" ]
                                                              • End If
                                                              • Show Custom Dialog [ Title: "OCR Loaded"; Message: $r; Default Button: “OK”, Commit: “Yes” ]
                                                              • End If
                                                              Fields used in this script
                                                                Scripts used in this script
                                                                  Layouts used in this script
                                                                    Tables used in this script
                                                                      Table occurrences used by this script
                                                                        Custom Functions used by this script
                                                                          Custom menu set used by this script

                                                                            Previous Script: [Load Tesseract 5] Next Script: [Show Version]
                                                                            Script Name Run Tesseract 4 or 5.x
                                                                            Run script with full access privileges Off
                                                                            Siri Shortcut Visible Off
                                                                            Include In Menu Yes
                                                                            Layouts that use this script
                                                                              Scripts that use this script
                                                                              Script Definition
                                                                              Script Steps
                                                                              • #Init OCR
                                                                              • #where is data folder?
                                                                              • If [ MBS("isMacOS") ]
                                                                              • #get tessdata from homebrew
                                                                              • Set Variable [ $path; Value:"/usr/local/Cellar/tesseract-lang/4.1.0/share/tessdata" ]
                                                                              • Else If [ MBS("isWindows") ]
                                                                              • Set Variable [ $path; Value:"C:\Program Files\Tesseract-OCR\tessdata" ]
                                                                              • Else If [ MBS("isLinux") ]
                                                                              • #use default from installation
                                                                              • Set Variable [ $path; Value:"" ]
                                                                              • Else
                                                                              • Exit Script [ Result: "new platform?" ]
                                                                              • End If
                                                                              • Set Variable [ $r; Value:MBS( "OCR.Initialize"; $path; "eng") ]
                                                                              • Set Field [ OCR::Result; $r ]
                                                                              • If [ MBS("isError") ≠ 0 ]
                                                                              • Exit Script [ Result: $r ]
                                                                              • End If
                                                                              • Set Variable [ $rr; Value:MBS( "OCR.SetPageSegMode"; "Auto") ]
                                                                              • #Process Image
                                                                              • If [ 1 ]
                                                                              • #pass container directly
                                                                              • Set Variable [ $r; Value:MBS( "OCR.SetImageContainer"; OCR::Image) ]
                                                                              • Else If [ 0 ]
                                                                              • #pass native file path directly
                                                                              • Set Variable [ $r; Value:MBS( "OCR.SetImageFile"; "/Users/cs/Desktop/phototest.tif") ]
                                                                              • Else
                                                                              • #pass GraphicsMagick image
                                                                              • Set Variable [ $img; Value:MBS("GMImage.NewFromContainer"; OCR::Image) ]
                                                                              • Set Variable [ $r; Value:MBS( "OCR.SetImage"; $img) ]
                                                                              • Set Variable [ $r; Value:MBS( "GMImage.Destroy"; $img) ]
                                                                              • End If
                                                                              • #Do OCR
                                                                              • Set Field [ OCR::Text; MBS("OCR.GetTExt") ]
                                                                              • #Cleanup
                                                                              • Set Variable [ $r; Value:MBS( "OCR.CleanUp") ]
                                                                              Fields used in this script
                                                                              Scripts used in this script
                                                                                Layouts used in this script
                                                                                  Tables used in this script
                                                                                  Table occurrences used by this script
                                                                                  Custom Functions used by this script
                                                                                    Custom menu set used by this script

                                                                                      Previous Script: [Run Tesseract 4 or 5.x] Next Script: [Clear]
                                                                                      Script Name Show Version
                                                                                      Run script with full access privileges Off
                                                                                      Siri Shortcut Visible Off
                                                                                      Include In Menu Yes
                                                                                      Layouts that use this script
                                                                                        Scripts that use this script
                                                                                          Script Definition
                                                                                          Script Steps
                                                                                          • Show Custom Dialog [ Title: "Version"; Message: MBS("OCR.Version"); Default Button: “OK”, Commit: “Yes” ]
                                                                                          Fields used in this script
                                                                                            Scripts used in this script
                                                                                              Layouts used in this script
                                                                                                Tables used in this script
                                                                                                  Table occurrences used by this script
                                                                                                    Custom Functions used by this script
                                                                                                      Custom menu set used by this script

                                                                                                        Previous Script: [Show Version]
                                                                                                        Script Name Clear
                                                                                                        Run script with full access privileges Off
                                                                                                        Siri Shortcut Visible Off
                                                                                                        Include In Menu Yes
                                                                                                        Layouts that use this script
                                                                                                          Scripts that use this script
                                                                                                            Script Definition
                                                                                                            Script Steps
                                                                                                            • Replace Field Contents [ OCR::Result; Replace with calculation: "" ] [ No dialog ]
                                                                                                            • Replace Field Contents [ OCR::Text; Replace with calculation: "" ] [ No dialog ]
                                                                                                            Fields used in this script
                                                                                                            Scripts used in this script
                                                                                                              Layouts used in this script
                                                                                                                Tables used in this script
                                                                                                                Table occurrences used by this script
                                                                                                                Custom Functions used by this script
                                                                                                                  Custom menu set used by this script

                                                                                                                    Download example: OCR

                                                                                                                    Used functions: