移動端下載一個工具:IP攝像頭(app)
Android的下載地址:http://app.mi.com/details?id=com.shenyaocn.android.WebCam
下載安裝后,打開app后,點擊下方的“打開IP攝像頭服務器”(連上wifi,確保電腦與手機處在同一局域網內)。
然后,使用python進行opencv代碼調用部分:
import cv2
cv2.namedWindow("camera",1)
#開啟ip攝像頭
video="http://admin:admin@192.168.1.5:8081/" #此處@后的ipv4 地址需要改為app提供的地址
cap =cv2.VideoCapture(video)
while True:
# Start Camera, while true, camera will run
ret, image_np = cap.read()
# Set height and width of webcam
height = 600
width = 1000
# Set camera resolution and create a break function by pressing 'q'
cv2.imshow('object detection', cv2.resize(image_np, (width, height)))
if cv2.waitKey(25) & 0xFF == ord('q'):
cap.release()
cv2.destroyAllWindows()
break
# Clean up
cap.release()
cv2.destroyAllWindows()
