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

조회 수: 14 (최근 30일)
MathWorks Support Team
MathWorks Support Team 2021년 2월 1일
편집: cui,xingxing 2021년 2월 7일
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
MathWorks Support Team 2021년 2월 1일
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