how to get stream from Hikvision ipcam ?

asked 2018-08-21 10:21:11 -0600

jalal gravatar image

I have tried with this code. password is mypassword. This is hikvision version DS 2CD1021 I I make this code with opencv 2

import cv2

import numpy as np

capture = cv2.VideoCapture('http://admin:[email protected]:554/videoMain')

size = (int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)),int(capture.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)))

fourcc = cv2.cv.CV_FOURCC('M','J','P','G')

video = cv2.VideoWriter('d',fourcc, 1 ,size)

while (True):

ret, img = capture.read()

video.write(img)

cv2.imshow('forehead', img)

if(cv2.waitKey(27)!=-1):

    break

capture.release()

cv2.destroyAllWindows()

I have error:

Traceback (most recent call last): File "D:\Zachs\Document\foccus\TA\KODE\source_code\mog tanpa save.py", line 15, in <module> cv2.imshow('forehead', img) error: C:\build\2_4_winpack-bindings-win64-vc14-static\opencv\modules\highgui\src\window.cpp:261: error: (-215) size.width>0 && size.height>0 in function cv::imshow

edit retag flag offensive close merge delete

Comments

since this is windows, make sure, you have the opencv_ffmpeg_64.dll on the PATH.

(it contains all ipcam / video writing functionality)

berak gravatar imageberak ( 2018-08-21 10:45:05 -0600 )edit