import cv2
import numpy as np
# Change this URL to your ESP32 video stream URL
cap = cv2.VideoCapture('http://192.168.163.110/xiao/Hi-Xiao-Ling')
while True:
ret, frame = cap.read()
if not ret:
break
# Convert BGR to HSV
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
# Define the range of blue color in HSV
lower_blue = np.array([110, 50, 50])
upper_blue = np.array([130, 255, 255])
# Threshold the HSV image to get only blue colors
mask = cv2.inRange(hsv, lower_blue, upper_blue)
# Bitwise-AND mask and original image
result = cv2.bitwise_and(frame, frame, mask=mask)
cv2.imshow('Original', frame)
#cv2.imshow('Mask', mask)
cv2.imshow('Detected Blue Color', result)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()