diff --git a/mid_image.jpg b/mid_image.jpg new file mode 100644 index 0000000..d31e881 Binary files /dev/null and b/mid_image.jpg differ diff --git a/rectangle_edges.jpg b/rectangle_edges.jpg new file mode 100644 index 0000000..eb23c93 Binary files /dev/null and b/rectangle_edges.jpg differ diff --git a/shapeDetectionImageCrop.py b/shapeDetectionImageCrop.py new file mode 100644 index 0000000..cbfe812 --- /dev/null +++ b/shapeDetectionImageCrop.py @@ -0,0 +1,43 @@ +import cv2 + +# Load the image +image = cv2.imread("mid_image.jpg") + +# Convert image to grayscale +gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) + +# Resize the image to half its original size for display (pop up window) +scale_percent = 20 # percent of original size +width = int(gray.shape[1] * scale_percent / 100) +height = int(gray.shape[0] * scale_percent / 100) +dim = (width, height) + +resized_gray = cv2.resize(gray, dim, interpolation=cv2.INTER_AREA) + +# Show resized image +cv2.imshow("Detected Rectangle", resized_gray) +cv2.waitKey(0) +cv2.destroyAllWindows() + + +"""# Apply Gaussian blur +blur = cv2.GaussianBlur(gray, (5, 5), 0) + +# Run Canny edge detector +edges = cv2.Canny(blur, 50, 150) + +# Find contours +contours, _ = cv2.findContours(edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) + +# Select the largest contour (presumed to be the rectangle) +contour = max(contours, key=cv2.contourArea) + +# Draw the detected contour on a copy of the original image +output = image.copy() +cv2.drawContours(output, [contour], -1, (0, 255, 0), 3) + +# Save or show the result +cv2.imwrite("rectangle_edges.jpg", output) +cv2.imshow("Detected Rectangle", output) +cv2.waitKey(0) +cv2.destroyAllWindows()""" \ No newline at end of file diff --git a/spotify_template.png b/spotify_template.png new file mode 100644 index 0000000..d775283 Binary files /dev/null and b/spotify_template.png differ diff --git a/stream_logo.py b/stream_logo.py new file mode 100644 index 0000000..7b0147f --- /dev/null +++ b/stream_logo.py @@ -0,0 +1,44 @@ +import cv2 +from ultralytics import YOLO + +model = YOLO('yolov5s.pt') # Replace with your trained logo detection model path +cap = cv2.VideoCapture(0) # Webcam input + +if not cap.isOpened(): + print("Error: Could not open video stream.") + exit() + +while True: + ret, frame = cap.read() + if not ret: + break + + results = model(frame) + + for result in results: + boxes = result.boxes.xyxy.cpu().numpy() + scores = result.boxes.conf.cpu().numpy() + class_ids = result.boxes.cls.cpu().numpy() + + for box, score, cls_id in zip(boxes, scores, class_ids): + if score < 0.3: + continue + + x1, y1, x2, y2 = map(int, box) + label = model.names[int(cls_id)] + + # Draw bounding box and label + cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2) + cv2.putText(frame, f'{label} {score:.2f}', (x1, y1 - 10), + cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2) + + # Log detection to console + print(f"Detected: {label} | Confidence: {score:.2f} | Box: ({x1}, {y1}), ({x2}, {y2})") + + cv2.imshow('Logo Detection', frame) + + if cv2.waitKey(1) & 0xFF == 27: + break + +cap.release() +cv2.destroyAllWindows() diff --git a/video.py b/video.py deleted file mode 100644 index 7f235c9..0000000 --- a/video.py +++ /dev/null @@ -1,41 +0,0 @@ -import cv2 -from pyzbar import pyzbar -import subprocess - -def detect_qr_code(frame): - detected_barcodes = pyzbar.decode(frame) - for barcode in detected_barcodes: - if barcode.type == 'QRCODE': - return barcode.data.decode('utf-8') - return None - -def main(): - cap = cv2.VideoCapture(0) # open default USB camera (index 0) - if not cap.isOpened(): - print('Error: Cannot access camera') - return - - print('Starting camera. Press q to quit.') - - while True: - ret, frame = cap.read() - if not ret: - print('Error: Cannot read frame') - break - - qr_data = detect_qr_code(frame) - if qr_data: - print(f'Detected QR Code: {qr_data}') - # Call the play script with this QR code data as argument - subprocess.Popen(['python3', 'play_spotify.py', qr_data]) - break - - cv2.imshow('QR Code Detector', frame) - if cv2.waitKey(1) & 0xFF == ord('q'): - break - - cap.release() - cv2.destroyAllWindows() - -if __name__ == '__main__': - main() diff --git a/yolov5su.pt b/yolov5su.pt new file mode 100644 index 0000000..e6cba26 Binary files /dev/null and b/yolov5su.pt differ