python3+cv2+andiord安卓攝像頭

#coding=utf-8
import cv2
import time

if __name__ == '__main__':

cv2.namedWindow("camera",1)
#開啓ip攝像頭
video="http://192.168.31.49:8080/video"
capture =cv2.VideoCapture(video)

num = 0
while True:
success,img = capture.read()
cv2.imshow("camera",img)

#按鍵處理,注意,焦點應當在攝像頭窗口,不是在終端命令行窗口
key = cv2.waitKey(10)

if key == 27:
#esc鍵退出
print("esc break...")
break
if key == ord(' '):
#保存一張圖像
num = num+1
filename = "frames_%s.jpg" % num
cv2.imwrite(filename,img)


capture.release()
cv2.destroyWindow("camera")





注意紅色字體處,

這裏是IP攝像頭的服務地址列表:ide

  • http://192.168.31.49:8080/video 是 MJPEG URL.
  • http://192.168.31.49:8080/shot.jpg 獲取最新一幀
  • http://192.168.31.49:8080/audio.wav 是WAV格式的音頻流
  • http://192.168.31.49:8080/audio.aac 是AAC格式的音頻流(若是硬件支持的話)
  • http://192.168.31.49:8080/audio.opus 是Opus格式的音頻流
  • http://192.168.31.49:8080/focus 對焦攝像頭
  • http://192.168.31.49:8080/nofocus 釋放對焦
相關文章
相關標籤/搜索