0

我想使用 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)
4

1 回答 1

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)
于 2018-02-28T14:24:19.307 回答