0

i am trying to design new system in openCV but not able to capture stream from IP camera.

I've tried using different protocol like rtsp and http.

import numpy as np
import cv2

cap = cv2.VideoCapture('http://root:pass@192.168.1.114/mjpg/video.mjpg')

    while(True):

    ret, frame = cap.read()





    cv2.imshow('frame',frame)

    if cv2.waitKey(20) & 0xFF == ord('q'):

    break


   cap.release()
   cv2.destroyAllWindows()

[tcp @ 0x7ff4d705c440] Connection to tcp://192.168.1.114:80 failed: Operation timed out OpenCV: Couldn't read video stream from file "http://root:pass@192.168.1.114/mjpg/video.mjpg" Traceback (most recent call last): File "camera-test.py", line 14, in cv2.imshow('frame',frame) cv2.error: OpenCV(4.1.0) /tmp/opencv-20190505-12101-14vk1fh/opencv-4.1.0/modules/highgui/src/window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
  • I never managed to make it work with mjpg streams, but you can try a solution like [this one](https://stackoverflow.com/questions/21702477/how-to-parse-mjpeg-http-stream-from-ip-camera/21844162#21844162) or try the rtsp stream, googling a little you can see the link is more like: `rtsp://User:Pass@Camera_IP/axis-media/media.amp`. Sometimes you need to add a get parameter like `?whatever=.mp4` for the backend to know what codec to use.... – api55 Jul 17 '19 at 10:58
  • Have you checked if you can see stream using VLC? – py_ml Jul 17 '19 at 11:23
  • Guys i rest the camera and it done thing for me. Thank you –  Jul 17 '19 at 11:40

0 Answers0