我有一个问题,当扫描条码与斑马tc520k触摸电脑条码扫描仪。在我的情况下,有几个条形码打印彼此接近。但这只是我感兴趣的条形码之一。问题是,如果我没有瞄准正确的方向,扫描器就会在我感兴趣的条形码旁边扫描错误的条形码。我要扫描的特定条形码是一种特定的值格式,格式是由9位数字(0-9)组成的值。例如:“123456789”或“012301231”。在androidjavaemdk中是否有一个内置的特性、方法或属性可以用来过滤我感兴趣的特定条形码?我该怎么做?
我看到有一个选择不同解码器的选项,但我认为这不够具体到只针对值为9位的条形码。
澄清图片:
谢谢!
更新:
我试着设置解码器 code128
长度为9 length1
以及 length2
. 但是条形码扫描器仍然扫描所有的条形码,不仅仅是长度为9位的条形码。下面是如何初始化扫描仪并设置扫描仪配置:
// Method to initialize and enable Scanner and its listeners
public void initializeScanner() throws ScannerException {
if (scanner == null) {
// Get the Barcode Manager object
barcodeManager = (BarcodeManager) this.emdkManager
.getInstance(EMDKManager.FEATURE_TYPE.BARCODE);
// Get default scanner defined on the device
scanner = barcodeManager.getDevice(BarcodeManager.DeviceIdentifier.DEFAULT);
// Add data and status listeners
scanner.addDataListener(this);
scanner.addStatusListener(this);
// Hard trigger. When this mode is set, the user has to manually
// press the trigger on the device after issuing the read call.
// scanner.triggerType = Scanner.TriggerType.HARD;
scanner.triggerType = Scanner.TriggerType.SOFT_ALWAYS;
// Enable the scanner
scanner.enable();
// Scan Mode set to Multi Barcode
ScannerConfig sc = scanner.getConfig();
sc.readerParams.readerSpecific.imagerSpecific.scanMode = ScannerConfig.ScanMode.SINGLE_BARCODE;
sc.decoderParams.code128.length1 = 9;
sc.decoderParams.code128.length2 = 9;
sc.readerParams.readerSpecific.imagerSpecific.beamTimer = 0;
sc.readerParams.readerSpecific.imagerSpecific.aimTimer = 0;
scanner.setConfig(sc);
// Starts an asynchronous Scan. The method will not turn ON the
// scanner. It will, however, put the scanner in a state in which
// the scanner can be turned ON either by pressing a hardware
// trigger or can be turned ON automatically.
try {
scanner.addDataListener(this);
// Scan Mode set to Multi Barcode
//ScannerConfig sc = scanner.getConfig();
sc.readerParams.readerSpecific.imagerSpecific.scanMode = ScannerConfig.ScanMode.SINGLE_BARCODE;
// Thread.sleep(100);
sc.decoderParams.code128.length1 = 9;
sc.decoderParams.code128.length2 = 9;
sc.readerParams.readerSpecific.imagerSpecific.beamTimer = 0;
sc.readerParams.readerSpecific.imagerSpecific.aimTimer = 0;
// Thread.sleep(100);
scanner.setConfig(sc);
// scanner.read();
} catch (Exception e) {
e.printStackTrace();
}
}
}
我必须禁用所有其他解码器才能工作吗?我必须只启用 code128
还是怎么了?
1条答案
按热度按时间v7pvogib1#
是的,这可以使用emdk在每个符号的基础上完成。在“解码器参数”下,选择解码器,例如“代码128”,并将“长度1”和“长度2”设置为相同的值(在案例9中)。