NaturalHistoryMuseum / pylibdmtx

Read Data Matrix barcodes from Python 2 and 3.
MIT License
145 stars 56 forks source link

missing documentation about decode arguments #49

Open mmortazavi opened 5 years ago

mmortazavi commented 5 years ago

This issue is duplicated in the original libdmtx repo, see here.

I have been struggling to read some of my data matrices which looked pretty decent in terms of quality. I did quite few enhancement like cv2.fastNlMeansDenoisingColored, cv2.threshold and so on. With these improvements I have had some success, but still missing quite few readings. It was funny that I could read some of my blurred, partly damaged data matrices, but missing good ones. It was rather a random behavior to be honest.

Until I learned that decode function takes quite a few number of parameters:

decode(
    image,
    timeout=None,
    gap_size=None,
    shrink=1,
    shape=None,
    deviation=None,
    threshold=None,
    min_edge=None,
    max_edge=None,
    corrections=None,
    max_count=None,
)

BUT there are not documentations what these arguments are. Some surely can be guessed, but others I could not guess what values to put in. A better documentation would be really appreciated. The reason I emphasize having one that, in my case, I came across this post in stackoverflow, and shrink was one recommended to play with. I started seeing magic. I basically, out of blue, screened some values shrink = np.arange(1,10) and I could read the data matrices that I was struggling with. The problem is that now it is not fixed shrink value, sometimes higher value, sometimes lower! I have to scan for each reading this range!

This bring to the significance of knowing more about arguments of this function!

tayounrony commented 2 years ago

This is a wrapper for the "libdmtx" package. Here is the documentation for the parameters http://libdmtx.sourceforge.net/display.php?text=dmtxread.1

And the arguments for the wrapper decode function are as follows:

Args:
    image: `numpy.ndarray`, `PIL.Image` or tuple (pixels, width, height)
    timeout (int): milliseconds
    gap_size (int):
    shrink (int):
    shape (int):
    deviation (int):
    threshold (int):
    min_edge (int):
    max_edge (int):
    corrections (int):
    max_count (int): stop after reading this many barcodes. `None` to read
        as many as possible.

Returns:
    :obj:`list` of :obj:`Decoded`: The values decoded from barcodes.
"""

Cheers,

Mohamed-Taha-Sta commented 2 months ago

Though this is very appreciated, I would love to see explicit doucmentation for these args.

Mohamed-Taha-Sta commented 2 months ago

This a comment by Gautam Dobariya on stack overflow.

I found it to be useful so I'm sharing it here.

"I am also using this library for decoding data matrix and i found something about these arguments that timeout is int value in milliseconds which is really helping for quickly decoding and gap_size is no of pixels between tow data matrix used when you have more than one data matrix in sequence to decode with equal gap. with threshold you can directly give threshold value between 0-100 to this function without using open-CV functions and max count is no of data matrix to be decode in one image and shape is data_matrix size i. for 1010 it is 0, 1212 it is 1 and so on. by using all these together we can have quick and effective decoding of data matrix."