import cv2
cap = cv2.VideoCapture('http://192.168.163.110/xiao/Hi-Xiao-Ling')
while True:
ret, frame = cap.read()
if not ret:
break
# Convert to grayscale
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# Apply Canny edge detection
edges = cv2.Canny(gray, 100, 200)
# Find contours
contours, _ = cv2.findContours(edges, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# Draw all contours
cv2.drawContours(frame, contours, -1, (0, 255, 0), 3)
cv2.imshow('Regular', frame)
cv2.imshow('Edges', edges)
cv2.imshow('Frame with Contours', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()