Quick barcode scanning

Here is my code (and it works correctly):

document.addEventListener('deviceready', myDeviceReady, false); function myDeviceReady() { $('#Print').append('Device is ready'); function Scan() { try { $('#Print').append('Scanning') window.plugins.barcodeScanner.scan(mySuccess,myError); } catch (myCatch) { $('#Print').append('catch: ' + myCatch) Scan(); } } function mySuccess(result) { if (result.cancelled) { $('#Print').append('The user cancelled the scan.') } else { $('#Print').append(result.text); $('#Print').append(result.format); } Scan(); } function myError(error) { $('#Print').append('Scanning failed: ' + error); Scan(); } Scan(); } 

Q: Is there a way to poll the scanner faster? It takes a few seconds for each scan, and my users have TONS barcodes for scanning.

They used to scan with a wedge on a laptop, but now they want to use the iPad.

Edit:

Perhaps what I'm looking for is a third-party solution.

+4
source share
3 answers

If your HTML is huge (where getting a DOM node via $ ('# Print') may take some time), or you have been using the application for a long time (in this case .append may slow down, since it never clears), in there is nothing wrong with your JavaScript code. In fact, I assume that the delay comes from your barcode plugin, not your JavaScript handler.

Before doing anything else, you should check if my assumption is true, and if there is a delay between your .barcodeScanner.scan () call and the mySuccess () / myFailure () functions.

PhoneGap seems to use ZXing ( "Zebra Crossing" ), which is the standard. If this is not so fast, you can try alternative libraries:

But it may happen that the autofocus speed on mobile cameras is not enough for your requirements, and you need laser-based equipment. This link contains a number of products that interact with equipment.

+2
source

If you use the official plugin in Cordova http://ngcordova.com/docs/plugins/barcodeScanner/

you can do it faster for iOS,

In your Xcode project, go to the plugins folder and open CDVBarcodeScanner.mm

change this line:

 captureSession.sessionPreset = AVCaptureSessionPresetHigh; 

for

 captureSession.sessionPreset = AVCaptureSessionPresetMedium; 
+2
source

In the previous assignment, I worked for CipherLab , a manufacturer of barcode scanners.

About barcode scanners

First of all, you need to clarify that this is not the scanner itself, but a slow one, but rather an application that reads it. The performance of the scanner itself is somewhat dependent on the price. If you have an inexpensive scanner, it can be slower, the cost of a good scanner will increase productivity as well as adaptability (the ability to read damaged / blurry / dirty barcodes). FYI, most mobile scanners do not have autofocus, as suggested by @Hazzit, but have a fixed, pre-focused lens that is optimized for a specific range of distances. If it is an image scanner (not a laser), scan the scanner by the barcode very close and pull it back until the scanner reads. End users quickly remember the “sweet spot” if they scan tons of barcodes. The laser scanner will only read 1D barcodes, but could potentially be faster and able to choose from a wider range of distances.

About your js code

It seems that the scanner plugin runs synchronously (blocks JS until it receives a barcode). Is there another feature in this library that will allow asynchronous use of the scanner? If not, look at another SDK to see if anyone else allows the asynchronous use of a barcode scanner.

Probably somewhat minor, but I will try to separate your JS DOM manipulation from the scanner code. DOM manipulation is potentially slow depending on the structure of the DOM, your selectors, and what you are doing.

If you can access the scanner asynchronously, you can disable them and do all your DOM manipulations “whenever possible” if the scanner does not block, waiting for the next barcode (basically, updating the user interface after you initiate the scanner, to accept the following barcode).

About scanning a keyboard wedge

Now, keyboard-wedge-style scanners obviously deliver data as quickly as they type, regardless of whether the application is ready for them or can keep up with keystrokes. It will be fast, but there will be no application level control.

You can make the Bluetooth barcode scanner work as a HID device (in fact, a “keyboard wedge” in modern technology), and it will work exactly as described above. Fast, there is still no control of the application level at the hardware level.

Of course, many of these bluetooth libraries also support the bluetooth profile for the SPP serial port, which gives you application level control. You can send commands / scanner configuration, and then read the scanned data.

It uses SDK tools. They simply read / write to the bluetooth serial port (scanner) to poll scanned barcodes. This can be very fast, but it will depend on the quality of the SDK. I am not an iOS programmer and I don’t know anything about this particular platform, but I know that on Windows these are high-level serial port access methods and low-level methods that are much more efficient.

At the same time, you still have the opportunity to return to keyboard cling if you want! Just thought I'd say that.

Also in this wedge keyboard mode, the scanner data prefix using a keyboard shortcut is usually used. Most scanners can insert some additional keystrokes at the beginning or end of the scanned data. For example, you can configure the scanner to type F3+{barcode data}+Enter and view the page for this shortcut, move the focus to the correct input field and then accept the data.

If all else fails

If everything else fails and you just can't get the performance you need ... the only way is to write your own iOS app. Although the high-level tools are great, you will never get the performance of your own application no matter what (for hardware access or user interface performance).

+1
source

All Articles