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

  • Thread starter berkeman
  • Start date

berkeman

Mentor
55,699
5,781
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
 

Attachments

anorlunda

Mentor
Insights Author
Gold Member
7,499
4,233
I don't know the answer, but I would search for a phone app.
 
10,929
4,438
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.
 

berkeman

Mentor
55,699
5,781
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).
 

Borek

Mentor
28,036
2,546
I am pretty sure I saw an Android app for that, capable of scanning the code and transferring it to the computer.
 

berkeman

Mentor
55,699
5,781

Attachments

Borek

Mentor
28,036
2,546
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.
 

Svein

Science Advisor
Insights Author
1,955
603
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
 

robphy

Science Advisor
Homework Helper
Insights Author
Gold Member
5,380
660
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)
)
 
1,366
717
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
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.
 

rbelli1

Gold Member
876
317
DOS box application
Is this DOSBox running a DOS application or windows running a DOS application or a windows console application?

BoB
 

berkeman

Mentor
55,699
5,781
Is this DOSBox running a DOS application or windows running a DOS application or a windows console application?

BoB
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.
 

rbelli1

Gold Member
876
317
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
 

robphy

Science Advisor
Homework Helper
Insights Author
Gold Member
5,380
660
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:
^+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:

Want to reply to this thread?

"Can a 2-D barcode scanner be used with OCR applications?" You must log in or register to reply here.

Related Threads for: Can a 2-D barcode scanner be used with OCR applications?

  • Posted
Replies
4
Views
3K
  • Posted
Replies
6
Views
28K
  • Posted
Replies
2
Views
1K
  • Posted
Replies
7
Views
12K
  • Posted
Replies
5
Views
333
Replies
6
Views
2K
  • Posted
Replies
6
Views
4K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top