使用Android IP Camera(python)在openCv中直播

时间:2012-11-05 21:41:59

标签: android python opencv stream

我想使用Android IP Camera在openCv中制作实时流,我一直在尝试使用此代码,但它不起作用。 我应该在这段代码中更改什么?

camera=cv.CaptureFromFile("http://192.168.0.10:8080/videofeed")
while True :
  img =cv.QueryFrame(camera)
  cv.ShowImage('Video',img)
  if cv.WaitKey(0):
    break   
cv.ReleaseCapture(camera)

1 个答案:

答案 0 :(得分:0)

import cv2
import numpy as np
import urllib



url = 'http://192.168.1.183:8080/shot.jpg'

while True:
    imgResp = urllib.urlopen(url)
    img = np.array(bytearray(imgResp.read()), dtype=np.uint8)
    img1 = cv2.imdecode(img, -1)
    #hsv = cv2.cvtColor(img1, cv2.COLOR_BGR2HSV)
    #lower_red = np.array([30,150,50])
    #upper_red = np.array([255,255,180])
    #mask = cv2.inRange(hsv, lower_red, upper_red)
    #res = cv2.bitwise_and(img1, img1, mask=mask)

    cv2.imshow('img',img1)
    cv2.waitKey(10)