Skip to main content

Read QR code from image using WeChat QR code reader in OpenCV

Project description

Read QR code

Description

This is a simple python script that reads a QR code from an image and prints the result. It uses the WeChat QR code reader API in OpenCV to read the QR code from a CV2 image.

Requirements

Important: This package requires opencv-contrib-python, NOT the standard opencv-python package.

Installation

Option 1: Install from pip (recommended)

pip install readQR

Option 2: Install from source

# Clone the repository
git clone https://github.com/CollinsWakholi/QR_Code.git
cd QR_Code

# Uninstall any existing opencv packages to avoid conflicts
pip uninstall opencv-python opencv-contrib-python -y

# Install dependencies (opencv-contrib-python includes all standard OpenCV features)
pip install -r requirements.txt

Note: If you have opencv-python installed, you MUST uninstall it first:

pip uninstall opencv-python opencv-contrib-python -y
pip install opencv-contrib-python>=4.5.0

The WeChat QR code detector is only available in opencv-contrib-python, not in the standard opencv-python package. Having both installed can cause conflicts.

Verify Installation

After installation, verify everything is set up correctly:

python check_installation.py

Usage

from readQR import ReadQR
import readQR.wechat_artefacts as artefacts
import cv2

art_dir = artefacts.__path__[0]
img = cv2.imread('test.png')
reader = ReadQR(artefact_path=art_dir)
show = None # Set to "single" or "continuous" to show the image with the QR code highlighted for single or continuous frames (video)
result = reader.decode(img, show=show)
[print(r) for r in result]

Sample input and output images

Input images

Output images

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

None

Acknowledgemnts

I am gratefully acknowledge Devin Rippner, ORISE, and the USDA for their invaluable assistance and funding support in the development of this Repo. This project would not have been possible without their guidance and opportunities provided.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

readqr-0.0.3.tar.gz (926.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

readqr-0.0.3-py3-none-any.whl (924.0 kB view details)

Uploaded Python 3

File details

Details for the file readqr-0.0.3.tar.gz.

File metadata

  • Download URL: readqr-0.0.3.tar.gz
  • Upload date:
  • Size: 926.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for readqr-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b8034d94a362a5e835b6df9fc4e8adbbcf99728e141053e7c8211755e4cfd6f3
MD5 36e8bf2dac2dcae0039e445a16fbe228
BLAKE2b-256 6382e579543f33f95cb66eeeec674232e15fb68b95e1fda8c65d7bceee83efae

See more details on using hashes here.

File details

Details for the file readqr-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: readqr-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 924.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for readqr-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e74d943947fba6c0d139822ccab65c066f85dcfd25d5041e1e0be5ce4fad78f5
MD5 bcdfdc80fa2ce085d6ef29c567dcf7eb
BLAKE2b-256 83870b9a98aafaee203d7dd186baf9ccdb31035dbd5150bfb74e0cebb9f45b54

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page