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

In summary, the script captures the output of the DOS box application and sends it to a C# Windows application running in the console window.
  • #1
berkeman
Mentor
66,848
19,523
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

  • upload_2018-8-16_8-7-15.png
    upload_2018-8-16_8-7-15.png
    14.6 KB · Views: 659
  • upload_2018-8-16_8-10-28.png
    upload_2018-8-16_8-10-28.png
    228 bytes · Views: 571
Computer science news on Phys.org
  • #2
I don't know the answer, but I would search for a phone app.
 
  • #3
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.
 
  • #4
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).
 
  • #5
I am pretty sure I saw an Android app for that, capable of scanning the code and transferring it to the computer.
 
  • #6
Borek said:
I am pretty sure I saw an Android app for that, capable of scanning the code and transferring it to the computer.
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
 

Attachments

  • upload_2018-8-16_10-45-5.png
    upload_2018-8-16_10-45-5.png
    46.6 KB · Views: 627
  • #7
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
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
 
  • #10
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)
)
 
  • Like
Likes berkeman
  • #11
berkeman said:
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.
 
  • #12
berkeman said:
DOS box application

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

BoB
 
  • #13
rbelli1 said:
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.
 
  • #14
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
 
  • Like
Likes berkeman
  • #15
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:
  • Like
Likes sysprog, berkeman and jim mcnamara

1. Can a 2-D barcode scanner be used to scan text for OCR applications?

Yes, a 2-D barcode scanner can be used to scan text for OCR (optical character recognition) applications. The scanner captures the image of the barcode, which contains encoded data, and then the OCR software can analyze and convert the text within the barcode into digital text.

2. What types of 2-D barcodes are compatible with OCR applications?

Most 2-D barcodes, such as QR codes and Data Matrix codes, can be read by OCR applications. However, the specific type of barcode and its size and resolution may affect the accuracy and speed of the OCR process.

3. Are there any limitations to using a 2-D barcode scanner with OCR applications?

While 2-D barcode scanners can be effective for OCR applications, there are some limitations to consider. For example, the scanner may not be able to read damaged or poorly printed barcodes, and the OCR software may struggle with certain fonts or languages.

4. Can a 2-D barcode scanner be used for real-time text recognition?

Yes, a 2-D barcode scanner can be used for real-time text recognition with OCR applications. This means that the scanner can quickly read and convert the text within a barcode into digital text, which can then be used for various purposes such as data entry or information retrieval.

5. How does the use of a 2-D barcode scanner with OCR applications benefit businesses?

The use of a 2-D barcode scanner with OCR applications can offer several benefits to businesses. It allows for faster and more accurate data entry, reduces the risk of human error, and can streamline various processes such as inventory management and document scanning. Additionally, it can save time and resources by eliminating the need for manual data entry.

Similar threads

Back
Top