Skip to content

Instantly share code, notes, and snippets.

@smith0022
Created July 10, 2023 18:12
Show Gist options
  • Save smith0022/d01e99c403a6936403b50456d54a5d89 to your computer and use it in GitHub Desktop.
Save smith0022/d01e99c403a6936403b50456d54a5d89 to your computer and use it in GitHub Desktop.
import cv2 as cv2
import numpy as np
import math as m
from picamera2 import Picamera2
cap = Picamera2()
cap.configure(cap.create_preview_configuration(main={"format": 'XRGB8888', "size": (640, 480)}))
cap.start()
while True:
img = cap.capture_array()
detect=cv2.QRCodeDetector()
value, points,cde = detect.detectAndDecode(img)
if value == "grab the bottle":
distan = 4.8*650/(points[0][2][1]- points[0][1][1])
print(str(distan))
key = cv2.waitKey(1)
if key == 83 or key == 113:
break
# import the necessary packages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment