- Code to batch generate QR codes from a csv file with headings. This is planned to be used with a file naming script here: https://github.com/markwhittyunsw/QR_image_renamer.
- Author: Mark Whitty UNSW (the original version of this code was written while on sabbatical at Plant and Food Research New Zealand)
- [email protected]
- Source code: https://github.com/markwhittyunsw/GenerateQRCode
- MIT licence
- Please cite this paper if you use this code: Hill, G.N. and Whitty, M. A., Embedding metadata in images at time of capture using physical Quick Response (QR) codes, Information Processing & Management, 58(3), 2021, https://doi.org/10.1016/j.ipm.2021.102504
barcode-QRcode-generator_v4 [Path to csv file containing input data] [Path to output directory for PDF file]
- A column titled 'ID' is used as the code content, otherwise the code content is automatically generate from the headers and values
HINT: Use Terminal in PyCharm to run commands for installing packages using pip (not Python Console)
- install python 3.7.2 64 bit edition
- update pip: "python -m pip install --upgrade pip" from location of Python installation using Administrator privileged CMD shell.
- pip install numpy
- pip install opencv-contrib-python
- run barcode-QRcodeScannerPy.py to install OpenCV (cv2)
- pip install pyinstaller # Optional - only for making an exe
- pip install ipywidgets # Optional, only for a jupyter notebook
- jupyter nbextension enable --py widgetsnbextension # Optional, only for a jupyter notebook
- pip install matplotlib
- Install shapely
- https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely
- Then find corresponding wheel 'cp37' in wheel filename must match python version.
- File --> Settings --> Project: --> Project Interpreter --> select existing project interpreter showing all packages installed (saves reinstalling them in a new virtual environment)
https://medium.com/dreamcatcher-its-blog/making-an-stand-alone-executable-from-a-python-script-using-pyinstaller-d1df9170e263 pip install pyinstaller
20190326 Fixing bug in pyzbar when trying to use pyinstaller. NaturalHistoryMuseum/pyzbar#27 Specifically
- Generate the <project_name>.spec file by trying to run pyinstaller (it may fail or work, or the exe may give an error relating to not being able to find a module names libiconv.dll or libzbar-64.dll)
- Edit the .spec file generated by pyinstaller to include the following lines: from pathlib import Path from pyzbar import pyzbar ... # dylibs not detected because they are loaded by ctypes a.binaries += TOC([ (Path(dep._name).name, dep._name, 'BINARY') for dep in pyzbar.EXTERNAL_DEPENDENCIES ])
- Rerun pyinstaller with the .spec file as an argument (before the .py file)
- The .exe works! Otherwise put libiconv.dll in the same folder as the dll.
Notice if jpg is created, this might need additional lines in .spec as the github link above shows.
- Generate QR codes in Python
- Generate QR codes with human-readable labels in Python
- Also removes strange characters
- Add timestamp live (not in this committed module)
- Generate PDF (not in this committed module) - PyFPDF good, but doesn't include bookmarks, https://www.blog.pythonlibrary.org/2018/06/05/creating-pdfs-with-pyfpdf-and-python/ - ReportLabs more complex: - http://www.devshed.com/c/a/python/python-for-pdf-generation/
- Make code distributable (pyinstaller)
- High speed update (real-time?) useful for timestamping image capture delays? (See v2 of QR-code-generator) (not in this committed module)
- Given the list of generated QR codes and processed set of codes should have same filenames, can have a tool to compare them and identify duplicates and missing items.
- Encode scale into the QR code, so its distance from the reader is known (assume printed correctly)
- Web interface: http://webpy.org/, http://flask.pocoo.org/, https://blog.pythonanywhere.com/169/
- Add website detailing the project and a fixed QR code which points to it, automatically generated on the cover of each document.
- Add column containing bookmarks
- Add column containing the actual code to embed (so can be user-defined), otherwise automatically generate it
- Add GUI to select a file
- Add GPS location live
- Add orientation live
- Q: How to make into a Python module?
- Q: How to make into a Jupyter notebook? And import the module.
- [Paused] Executable or wrap Python in R or wrap R in Python?
- [Paused] rPython to run Python code from R
- [Paused] Mlabwrap allows a bridge from Python to Matlab
- https://www.learnopencv.com/barcode-and-qr-code-scanner-using-zbar-and-opencv/
- https://sourceforge.net/projects/zbar/
- Generate QR code (https://cran.r-project.org/web/packages/qrcode/index.html)
- https://www.riverbankcomputing.com/software/pyqt/intro PyQT for integrating C+ Qt framework with Python.
- http://www.web2py.com/
- NBViewer.jupyter.org
- RPy2 library to run R code from within Python. (comparison infographic) https://www.datacamp.com/community/tutorials/r-or-python-for-data-analysis?utm_source=adwords_ppc&utm_campaignid=898687156&utm_adgroupid=48947256715&utm_device=c&utm_keyword=&utm_matchtype=b&utm_network=g&utm_adpostion=1t1&utm_creative=261400735633&utm_targetid=dsa-473406585795&utm_loc_interest_ms=&utm_loc_physical_ms=1011036&gclid=CjwKCAiAqaTjBRAdEiwAOdx9xp5-tFTtDESFPgomG_VaTJWdtOgl-3eXARrQTyRRkDcWCw4t9DeOBxoCr2oQAvD_BwE