Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async def scan_qr(area: int = 300, color: int = 196, side: int = 240, lang: str = "en", debug: bool = False) -> None:
- """Main function that creates a screen with the capture, monitors the web-cam's stream, searches for a QR-code in a squared area and passes
- the decoded QR-code to the notify module.
- Args:
- [optional] area (int): Minimal area of a detected object to be consider a QR-code.
- [optional] color (int): Minimal hue of gray of a detected object to be consider a QR-code (since QR-codes have white borders).
- [optional] side (int): Length of the side of a square to be drawn in the center of the screen and monitor the inside area for QR-codes.
- [optional] lang (str): Language of a text to be written above the square.
- [optional] debug (bool): Crops and outputs an image containing inside the square at potential detection.
- """
- kernel = np.ones((2, 2), np.uint8)
- square = create_square(cap.read()[1], side=side)
- while cap.isOpened():
- ret, frame = cap.read()
- key = cv2.waitKey(1)
- if not ret or square is None or ((key & 0xFF) in {27, ord("Q"), ord("q")}):
- exit(1)
- image = draw_bounds(frame, square, lang=lang)
- detected, cropped = detect_inside_square(frame, square, kernel, area_min=area, color_lower=color, debug=debug)
- if detected:
- address = detect_qr(cropped)
- if address:
- await notify.start(address)
- cv2.imshow("Live Capture", image)
- time.sleep(0.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement