Why can't the 'readBarcode' function read my barcode?

12 次查看(过去 30 天)
I am using 'readBarcode' from the Computer Vision Toolbox to read an Aztec barcode. The function appears to execute properly, and no error messages appear. However, the output string, the detected format and the location returned by the function are empty. What are the troubleshooting steps for this issue?

采纳的回答

MathWorks Support Team
Please follow the steps below to troubleshoot 'readBarcode' issues:
1.    If the barcode is not clear, then preprocessing steps will help enhancing the barcode to improve reading. For poorly aligned barcodes, you can use 'imrotate' and for noisy barcodes you can use 'imsharpen'. In case of poor contrast you can try the following:
I = imread("Figure2.jpg");
Igray = rgb2gray(I);
BW = imbinarize(I, 0.3);
readBarcode(BW)
2.    If your image is an indexed image, then the barcode may not be detected directly.
You should do the following:
[X, cmap] = imread("6.png"); % Get the colormap as well
% Notice the difference
figure; imshow(X);
figure; imshow(X. cmap);
% Convert to RGB
RBG = ind2rgb(X, cmap);
While specifying the formats, they can be a barcode family ('1D', '2D'), or a string vector of format names, but not a mix of both, as done in test.m. Changing the call to:
[msg, format, loc] = readBarcode(I,"AZTEC");
or
[msg, format, loc] = readBarcode(I);
should work.
3.    If the output string of the 'readBarcode' is empty then the barcode reader could not detect the barcode and it could be because of various reasons like: the barcode is not a valid one, it is not in a supported format or the reader is simply unable to find it. Please check if the barcode is a valid one, if the barcode reader returns an empty string.

更多回答(1 个)

cui,xingxing
cui,xingxing 2021-2-7
编辑:cui,xingxing 2021-2-7

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by