Question list:
1. Data Matrix Scanning Questions
1.1 Why won't my image scan?
1.2 What can I do to improve performance?
2. Data Matrix Generation Questions
3. libdmtx C API Questions
3.1. Why does my call to dmtxRegionFindNext() always return NULL?
4. Command Line Utility Questions (dmtxread / dmtxwrite)
4.1. Why does dmtxread / dmtxwrite just hang when I run it without parameters?
4.2. dmtxwrite just write-bombed my terminal with binary data. What's your problem, man?
4.3. Why does dmtxread print out Ghostscript warnings?
5. ImageMagick Dependency Questions
5.1. Do I need to use ImageMagick?
5.2. Do I need to build ImageMagick from source?
5.3. How do I fix the following MS Visual Studio error when compiling?
6. libdmtx Wrapper Questions
7. libdmtx Project Questions
7.1. How do I join the libdmtx mailing lists?
8. Dragonfly Logic Questions
1. Data Matrix Scanning Questions
1.1 Why won't my image scan?
One (or several) known conditions may be conspiring against you to prevent a successful scan. Check if any of the following situations apply:
- Image quality (noisy, blurry, low contrast, etc…)
- Pre-ECC200 (old style) Data Matrix
- Insufficient "quiet zone"
The Data Matrix standard, and therefore libdmtx, requires a "quiet zone" to surround every barcode region. If your image is cropped so the Data Matrix symbol is touching or nearly touching the image boundary, this might be preventing a successful scan.
1.2 What can I do to improve performance?
2. Data Matrix Generation Questions
2.1. Any questions?
3. libdmtx C API Questions
3.1. Why does my call to dmtxRegionFindNext() always return NULL?
It's possible that your pixel data does not match the properties set by dmtxImageCreate() and dmtxImageSetProp(). For example, if your pixel data has 32 bits per pixel but you called:
dmtxImageCreate(pxl, 640, 480, DmtxPack24bppRGB); /* Should have used DmtxPack32bppRGBX */
… then libdmtx is seeing something very different than what you expected. Situations like this will usually prevent libdmtx from finding a valid barcode region (i.e., dmtxRegionFindNext() will return NULL), and can even trigger a SEGFAULT if libdmtx tries to read pixels beyond your image boundaries as a result.
To test if this is happening, try using the dmtxDecodeCreateDiagnostic() function in your program after the calls to dmtxImageCreate() and dmtxImageSetProp(). This function will return a pointer to a copy of your image in PNM format, which your program can write to the filesystem to be viewed with any image viewer. At that point it should be immediately apparent if there is a mapping issue somewhere. Check out the WriteDiagnosticImage() function in dmtxread.c to see a working example of this function being used.
If you find that your image appears upside-down, add the following call after dmtxImageCreate():
dmtxImageSetProp(img, DmtxPropImageFlip, DmtxFlipY);
4. Command Line Utility Questions (dmtxread / dmtxwrite)
4.1. Why does dmtxread / dmtxwrite just hang when I run it without parameters?
The dmtxread and dmtxwrite utilities are designed in the full Unix tradition, using the standard input and output streams whenever appropriate. Because of this, when you run either command without parameters it will sit forever waiting for input (except for in Windows, where it doesn't). This approach provides a flexible interface, allowing users and scripts to interact in whatever way makes sense. For example, the following examples all produce an equivalent result:
$ echo -n 123456 | dmtxwrite > image.png
$ echo -n 123456 | dmtxwrite -o image.png
$ echo -n 123456 > message.txt; dmtxwrite message.txt > image.png
$ dmtxwrite <(echo -n 123456) -o image.png
And here's something you can do simply because it's cool:
$ wget libdmtx.org/Images/generated.png -O- 2>/dev/null | dmtxread -n
4.2. dmtxwrite just write-bombed my terminal with binary data. What's your problem, man?
dmtxwrite writes to standard output by default. If you create a barcode and forget to specify or redirect the output, it will be written directly to your terminal. Most shells and terminals really don't like this, and it may look like the computer is swearing at you in a foreign language (e.g., @#%$!).
However, this design allows you to use the command in powerful combinations. The following commands are trivial examples, but they begin to show the type of thing that might otherwise be cumbersome or difficult:
$ echo -n 123456 | dmtxwrite | display # Display the image instead of saving
$ echo -n 123456 | dmtxwrite | md5sum # Generate MD5 checksum for image
$ echo -n 123456 | dmtxwrite | dmtxread # Create a barcode and read it back
$ echo -n 123456 | dmtxwrite -f svg | gzip > image.svg.gz
$ mkfifo dmtx_input # Create a named pipe
$ dmtxread -n dmtx_input & # Wait for input to decode
$ echo -n 123456 | dmtxwrite > dmtx_input # Create image and pass to dmtxread
Yeah, Unix is pretty awesome like that.
4.3. Why does dmtxread print out Ghostscript warnings?
Why, indeed. These messages appear when scanning a barcode from certain PDF or PS documents, and Ghostscript (which is called by ImageMagick) complains directly to the standard error stream. The messages seem pretty harmless overall, but they look bad and can be confusing to unsuspecting users. If someone has information on how to fix this without rebuilding Ghostscript from source, please speak up.
5. ImageMagick Dependency Questions
5.1. Do I need to use ImageMagick?
If you want to use dmtxread or dmtxwrite, yes. Otherwise, no. libdmtx itself (the library) does not use ImageMagick.
5.2. Do I need to build ImageMagick from source?
You certainly can, but usually it's not necessary.
Some Ubuntu users have reported an issue where the ImageMagick Wand API is missing from the normal pre-built packages. If libdmtx's "./configure" throws the following error, you might be one of the unlucky people who need to install ImageMagick from source.
checking for MAGICK... no
configure: error: dmtxread/dmtxwrite requires Wand >= 6.2.4
But don't give up hope yet. First make sure the ImageMagick runtime and development packages are installed (ImageMagick, libmagick, ImageMagick-devel, libmagick-dev, or something like that depending on your OS). If that doesn't fix the problem, try finding a file named "Wand.pc" somewhere on your computer, point the PKG_CONFIG_PATH environment variable to that directory, and re-run "./configure".
$ export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/ # Replace with directory that holds Wand.pc
$ ./configure
If "./configure" still won't run, you probably need to compile ImageMagick from source.
5.3. How do I fix the following MS Visual Studio error when compiling?
5.3.1 LNK1104: cannot open file 'CORE_RL_wand_.lib'
This error indicates that Visual Studio can't find your ImageMagick installation. It's possible that you didn't install ImageMagick yet, but it's more likely that you need to update the ImageMagick path in your project settings. Depending on your libdmtx version, this path setting is located in the [libdmtx]\project\visualc9\magick.vsproj file, or in the dmtxread.vcproj and dmtxwrite.vcproj files of the same directory.
5.3.2 LNK2019: unresolved external symbol impMagickRelinquishMemory referenced in function _ListImageFormats
The easiest solution is to use the pre-built ImageMagick package from SourceForge instead of trying to build it yourself. Beyond that, it probably makes sense to seek help from the ImageMagick developers.
6. libdmtx Wrapper Questions
6.1. Any questions?
7. libdmtx Project Questions
7.1. How do I join the libdmtx mailing lists?
You can subscribe to the various libdmtx mailing lists by filling out the following forms. You will be sent an email requesting confirmation for security purposes. This is a hidden list, so only the administrator has visibility to the full member list. Password reminders are sent in cleartext when requested, so do not use a valuable password.
- https://lists.sourceforge.net/mailman/listinfo/libdmtx-announcements
- https://lists.sourceforge.net/mailman/listinfo/libdmtx-development
- https://lists.sourceforge.net/mailman/listinfo/libdmtx-open_discussion