python+opencv 电脑调用手机的摄像头

移动端下载一个工具: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:[email protected]: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()

 

 

你可能感兴趣的:(python,OpenCV)