Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Can a 2-D barcode scanner be used with OCR applications?

  1. Aug 16, 2018 #1

    berkeman

    User Avatar

    Staff: Mentor

    I have a need for a hand-held scanner to be able to read a MAC ID displayed on a monitor. The MAC IDs are sent to my application via a network, and I need to automatically read each MAC ID into a different application. For various reasons (Linux versus Windows applications running on different computers), it would be easiest if I could just use a hand-held scanner to capture the MAC ID into an application.

    Has anybody seen Optical Character Recognition (OCR) in a simple hand-held scanner device? I guess I could write my own application based on a cell phone camera or similar, but if such an OCR application exists already for 2-D barcode scanner wands, that would be the quickest way to solve this problem. Thanks.

    upload_2018-8-16_8-10-28.png

    upload_2018-8-16_8-7-15.png
     
  2. jcsd
  3. Aug 16, 2018 #2

    anorlunda

    Staff: Mentor

    I don't know the answer, but I would search for a phone app.
     
  4. Aug 16, 2018 #3

    jedishrfu

    Staff: Mentor

    Alternatively you could have the computer display a barcode version of the number and then scan it that way.

    However, I think @anorlunda's suggestion is the best one.
     
  5. Aug 16, 2018 #4

    berkeman

    User Avatar

    Staff: Mentor

    It's to retrofit a manufacturing test fixture in China that has one Windows laptop and one Linux laptop. The MAC ID shows up in a DOS box application on the Windows PC, and we need to enter it into the Linux PC's test program. If the scanner's program could read the MAC ID text displayed in the DOS box and output the characters via USB, that would be ideal (like a barcode scanner just outputs the text version of the barcode, so simple console apps can take the data in).
     
  6. Aug 16, 2018 #5

    Borek

    User Avatar

    Staff: Mentor

    I am pretty sure I saw an Android app for that, capable of scanning the code and transferring it to the computer.
     
  7. Aug 16, 2018 #6

    berkeman

    User Avatar

    Staff: Mentor

    Do you mean an app for scanning a barcode or QR code? I use the Android app "QR and Barcode Scanner" for that, and it works okay. But this current requirement is different (recognizing characters and sending them over USB as a text stream).

    https://play.google.com/store/apps/details?id=me.scan.android.client&hl=en_US

    upload_2018-8-16_10-45-5.png
     
  8. Aug 16, 2018 #7

    Borek

    User Avatar

    Staff: Mentor

    Sorry, missed the part about the ID being text :frown:

    There are OCR apps, but no idea if they can be used to send the ocr-ed text to the computer.
     
  9. Aug 16, 2018 #8

    jedishrfu

    Staff: Mentor

  10. Aug 18, 2018 #9

    Svein

    User Avatar
    Science Advisor

    If you are writing the application, consider using a pipe between the programs. You can do it at the command level:

    MACapp | YourApp

    It is slightly more difficult if the apps are on different computers. I guess something like this would need to be prettied up:

    MACapp | //YourPC/Appdir/YourApp
     
  11. Aug 19, 2018 #10

    robphy

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Do you have the ability to install a program on the PC running the DOS box?
    Does that PC also have networking capabilities with your linux box?

    If so, you can write an AutoHotkey script that can detect the DOS box
    then capture the text (as text) then process it (to extract the MAC ID), then send it via the network to your linux box.
    No image processing, OCR, or additional hardware is needed.

    https://www.google.com/search?q=autohotkey+dosbox+text+capture
    https://autohotkey.com/

    (along the line of OCR on a smartphone, I think this is pretty neat...
    https://www.microsoft.com/en-us/seeing-ai (for iOS)
    )
     
  12. Aug 21, 2018 #11
    As I recall there was a way to redirect the standard DOS output to serial port, for example.
    But it is an old story, and things might be different under a windows console.
     
  13. Sep 3, 2018 #12

    rbelli1

    User Avatar
    Gold Member

    Is this DOSBox running a DOS application or windows running a DOS application or a windows console application?

    BoB
     
  14. Sep 4, 2018 #13

    berkeman

    User Avatar

    Staff: Mentor

    There is a DOS application running in the DOS box that receives a MAC ID over a network (and doesn't have an easy way to pipe that MAC ID to another application). That MAC ID then needs to be printed out on a barcode label via a C++ or C# Windows application. Right now it is typed into the C++ program manually, leading to human error too often. We are just looking for a simple short-term fix before we re-write the old DOS application as a Windows application.
     
  15. Sep 4, 2018 #14

    rbelli1

    User Avatar
    Gold Member

    If the old application is using the console rather than drawing on the screen you should be able to execute the application as a child process and capture the console streams. Then you can parse out the MAC.

    BoB
     
  16. Sep 4, 2018 #15

    robphy

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    I got the following to work.

    I installed AutoHotKey ( https://autohotkey.com/ ) on my Windows 10 machine (although I have used an old version of it since Windows XP).
    I have a console window on my desktop.
    The following script does the following steps:
    When ctrl-shift-q is pressed,
    if a window with the title Command Prompt exists [and I am assuming that it's a console window],
    it clicks the upper left corner of the window, hits (e)dit, then mar(k).
    It clicks in the client region [where the text is visible] at the upper-left corner of the console.
    Then either
    • Method 1:
      It sends ctrl-a, then hits ENTER.
      The entire console buffer is captured into the clipboard as text.
    • Method 2:
      Starting from a point near the click, it click-drags to the opposite corner of the console window
      then hits ENTER.
    For the purposes of this demo, the clipboard will display in a Message Box... but you don't need to.
    AutoHotKey can now process the text (search for a MAC address, if you teach it to),
    and then do something [like write a file, or possibly send an email, etc...]

    Rather than hit a keystroke (like ctrl-shift-q),
    a script can watch for a window (or some other condition), then continue when it is found.
    https://autohotkey.com/docs/commands/WinWait.htm

    You can also just loop and keep checking at some interval you set.


    Code (Text):

    ^+q::
    IfWinExist, Command Prompt
    {
        WinActivate
        Click,20,10
        Send,e
        Sleep,200
        Send,k
        Click,10,40
        SLeep,500

        if 1
        {
            Send,^a{ENTER}
        }
        else
        {
            ;;;method2
            WinGetPos,X,Y,W,H, Select Command Prompt ; title changed after 500ms since the click
            Sleep,200
            MouseClickDrag, left, 12,40, W-50,H-50,0 ; 0=fastest, 100=slowest
            Send,{ENTER}
        }
        MsgBox ,  %clipboard%
    }
    return
     
    AutoHotKey can be installed on the computer running the DOSbox.
    However, you can also install AutoHotKey on another computer, then get AutoHotKey to compile the script into an executable.
    That executable can be copied to the computer running the DOSbox and should be able to run without installing AutoHotKey on it.

    https://autohotkey.com/docs/commands/RegExMatch.htm
    https://autohotkey.com/docs/commands/SubStr.htm
    https://autohotkey.com/board/topic/123886-send-email-from-script/
     
    Last edited: Sep 5, 2018
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted