Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3854

General discussion • QR code scan using Arducam multi cam adapter

$
0
0
i am trying to set up 2 cameras, 1 to scan a QR code and 1 to take a picture of the person scanning. Because of this i am using an arducam multicam adapter v2.2 the code that i am working on isnt working and is starting to frustrate me. The camera i am trying to use to scan the qr code is setup in port b and i have tested the cameras and they are both working. Here is my code:

import cv2
from datetime import datetime
import time
import RPi.GPIO as gp
import os

gp.setwarnings(False)
gp.setmode(gp.BOARD)

# Setup GPIO pins for LED control
gp.setup(7, gp.OUT) # Red LED
gp.setup(11, gp.OUT) # Green LED
gp.setup(12, gp.OUT) # Blue LED

# Create camera object for the camera connected to Port B
camera = cv2.VideoCapture(0) # Adjust index if necessary

# QR code detection method
detector = cv2.QRCodeDetector()

# Infinite loop to keep searching for QR codes
while True:
# Capture frame from the camera
ret, img = camera.read()
if ret:
# Detect QR code in the frame
data, bbox, _ = detector.detectAndDecode(img)
if bbox is not None:
# Draw bounding box and display data
for i in range(len(bbox)):
cv2.line(img, tuple(bbox[0]), tuple(bbox[(i+1) % len(bbox)][0]), color=(255, 0, 0), thickness=2)
cv2.putText(img, data, (int(bbox[0][0][0]), int(bbox[0][0][1]) - 10), cv2.FONT_HERSHEY_SIMPLEX,
1, (255, 250, 120), 2)

# Print QR code data
if data:
print("Data found:", data)
# Add logic to control LEDs based on data
if data == 'red':
pass
elif data == 'green':
pass

# Display camera feed
cv2.imshow("Camera", img)

# Break loop if 'q' is pressed
if cv2.waitKey(1) == ord("q"):
break

# Release resources
camera.release()
cv2.destroyAllWindows()

And this is the error i am getting:

[ WARN:0@0.501] global ./modules/videoio/src/cap_gstreamer.cpp (1405) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile
libpng warning: iCCP: known incorrect sRGB profile

Any help would be appreciated

Statistics: Posted by coderedd123 — Sat Mar 30, 2024 1:06 am



Viewing all articles
Browse latest Browse all 3854

Trending Articles