Skip to content

Instantly share code, notes, and snippets.

View Lenni's full-sized avatar

Lennart Wilde Lenni

  • RWTH Aachen University
  • Germany
View GitHub Profile
@Lenni
Lenni / qr.py
Created July 2, 2022 21:08
QR Code Deskewing and Decoding
import cv2
import numpy as np
def extract_qr(filename):
image = cv2.imread(filename)
image = cv2.resize(image, None, fx=1 / 10, fy=1 / 10, interpolation=cv2.INTER_AREA)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
gray = 255 - gray
thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1]