This repository is just a single file built on python data matrix readers and encoders. Running this script allows you to read any data matrix using your camera or encode any allowed data into a data matrix using the command line. You can also use this as a module and expand beyong this single script.
Make sure the place you install this has camera permissions on your device.
- All code is written in Python 3.
- Dependencies are contained in the
dependencies.txt
file - This script is built upon
OpenCV-2
&pylibdmtx
- Start by cloning this repository.
- The main file is called
pydmatrix.py
- YOU HAVE TO OPEN THIS IN AN ENVORIONMENT THAT HAS PREMISSION TO ACCESS YOUR CAMERA
- Navigate to the dependencies file directory.
- Run
pip3 install -r dependencies.txt
- Navigate to the script directory.
Decoding
- Run
python3 pydmatrix.py
- It will ask you if you want to encode or decode. Select decode.
- It will ask you if your image needs to be fliped. On some webcams, this will be needed. You can do multiple tests, to see if it is needed.
- Your computer may ask for you to allow your command line to access to the camera. Select allow.
- 3 different video feeds should pop up. Left will be the raw video; Center will be the threshold filtered; Right will be the contour detection results.
- Another window with adjustable sliders will open as well. These control the threshold and countour min & max values. There is also one for area threshold.
- Hold your data matrix into frame. Check the center feed to make sure all parts are being converted properly. You may need to adjust these values based on lighting.
- The data matrix must be detected within frame for 200 consecutive frames.
- Once that threshold is reached, give it a few seconds to process and the resultign data should be displayed in your command line.
Encoding
- Run
python3 pydmatrix.py
- It will ask you if you want to encode or decode. Select encode.
- It will ask you for the data you wish to encode.
- Enter your data and press enter.
- Data matrix can only encode up to 3116 ASCII characters. Read more here.
- The program will encode and spit out the resulting data matrix image to the root directory of the script.
import pydmatrix
- To encode, call the function
writtingEncode()
. - To decode, call the function
readingDecode()
.
- Currently, because of how the code is setup, it will call the entire process after you choose whether to encode or decode as if you ran this script. You can change it so that it is seperated into more spcialized tasks and whatnot. There are already some within the code that you can explore for yourself.
This project is released under the MIT lisence. Anyone can change, add, delete, and alter the code in whatever way the may like. You may create a pull request at any time but spams will be blocked. Rejects and accepts will not be checked on a regular basis.
Note: This project is unmaintained. You can submit issues and requests. However, they will be resolved at times only convient and available to me.