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

#### berkeman

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.

#### Attachments

• 25.3 KB Views: 337
• 225 bytes Views: 288
Related Computing and Technology News on Phys.org

#### anorlunda

Mentor
Gold Member
I don't know the answer, but I would search for a phone app.

#### jedishrfu

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.

#### berkeman

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

#### Borek

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

Mentor

#### Attachments

• 63.9 KB Views: 269

#### Borek

Mentor
Sorry, missed the part about the ID being text

There are OCR apps, but no idea if they can be used to send the ocr-ed text to the computer.

Mentor

#### Svein

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

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://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)
)

#### Rive

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
DOS box application
Is this DOSBox running a DOS application or windows running a DOS application or a windows console application?

BoB

#### berkeman

Mentor
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
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

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:
^+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:

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

### 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