When I provide -N 1 to dmtxread, I am assuming that I know there's exactly one barcode in each image and that it should only return one barcode per image. However, if I specify more than one image either as multiple files or as one multi-page file, the program behaves incorrectly. Usually it works (i.e. one barcode is printed for the image). However for some images, it does not print any barcode whereas it will print the barcode if I leave out the -N 1.
The problem is the loop at line 149 in dmtxread.c. The check for imgScanCount >= opt.stopAfter is at the end of the loop. If I've previously found a barcode, imgScanCount will be >= 1. On certain images, dmtxRegionFindNext will return successfully, but dmtxDecode will fail. This causes the program to give up even though I haven't yet found a good barcode for the image. The second time through the loop, the program would find a barcode successfully.
A fix that works for me is to change the condition on line 178 from imgScanCount to pageScanCount >= opt.stopAfter