Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Heng__Chin
Beginner
577 Views

how to use IP cam with openvino

can openvino use with IP cam instead of web cam ? if yes, how to setup ?

0 Kudos
8 Replies
Hyodo__Katsuya
Innovator
577 Views

@Heng, Chin Regardless of the function of OpenVINO, it can be processed by OpenCV. https://stackoverflow.com/questions/49978705/access-ip-camera-in-python-opencv
Heng__Chin
Beginner
577 Views

@Hyodo, Katsuya

 

import numpy as np

import cv2 cap = cv2.VideoCapture('http://username:password@10.10.XX.XX')

while(True): ret, frame = cap.read()

cv2.imshow('frame',frame)

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

break

cap.release()

cv2.destroyAllWindows()

 

tested code above but not working, and got this message below:

 

user@user-virtual-machine:~/Downloads$ python3 ipcam.py

(python3:4185): GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed
Traceback (most recent call last):
  File "ipcam.py", line 16, in <module>
    cv2.imshow('frame',frame)
cv2.error: OpenCV(4.0.0-pre) /home/jenkins/workspace/OpenCV/OpenVINO/build/opencv/modules/highgui/src/window.cpp:356: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

Hyodo__Katsuya
Innovator
577 Views

You need to replace 1.username 2.password 3.ipaddress 4.port 5.path(xxxx) with the correct value. import cv2 cap = cv2.VideoCapture("http://username:password@xxx.xxx.xxx.xxx:port/xxxx") #cap = cv2.VideoCapture("http://username:password@xxx.xxx.xxx.xxx:port") while(True): ret, frame = cap.read() cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows() or import cv2 cap = cv2.VideoCapture("rtsp://username:password@xxx.xxx.xxx.xxx/1") while(True): ret, frame = cap.read() cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows() If there is no authentication setting, import cv2 cap = cv2.VideoCapture("http://xxx.xxx.xxx.xxx:port/xxxx") #cap = cv2.VideoCapture("http://xxx.xxx.xxx.xxx:port") while(True): ret, frame = cap.read() cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows() or import cv2 cap = cv2.VideoCapture("rtsp://xxx.xxx.xxx.xxx/1") while(True): ret, frame = cap.read() cv2.imshow('frame',frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows()
Heng__Chin
Beginner
577 Views

@Hyodo, Katsuya

replaced username,password,port with correct value still having same output

cap = cv2.VideoCapture("http://username:password@xxx.xxx.xxx.xxx:port")

user@user-virtual-machine:~/Downloads$ python3 ipcam.py 
[http @ 0x1e3d320] Stream ends prematurely at 0, should be 1581

(python3:5253): GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed
Traceback (most recent call last):
  File "ipcam.py", line 17, in <module>
    cv2.imshow('frame',frame)
cv2.error: OpenCV(4.0.0-pre) /home/jenkins/workspace/OpenCV/OpenVINO/build/opencv/modules/highgui/src/window.cpp:356: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

 

if using rtsp will get message below

cap = cv2.VideoCapture("rtsp://username:password@xxx.xxx.xxx.xxx/1")

user@user-virtual-machine:~/Downloads$ python3 ipcam.py 
[rtsp @ 0x2335920] method OPTIONS failed: 404 Not Found

(python3:5298): GStreamer-CRITICAL **: gst_element_get_state: assertion 'GST_IS_ELEMENT (element)' failed
Traceback (most recent call last):
  File "ipcam.py", line 17, in <module>
    cv2.imshow('frame',frame)
cv2.error: OpenCV(4.0.0-pre) /home/jenkins/workspace/OpenCV/OpenVINO/build/opencv/modules/highgui/src/window.cpp:356: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'

 

Hyodo__Katsuya
Innovator
577 Views

I do not know the type of camera you are using, so further advice is difficult.
Heng__Chin
Beginner
577 Views

I'm using DVR model: HV7108

Hyodo__Katsuya
Innovator
577 Views

??? Probably, It is not a network camera. I do not know what you want to do.
Jia__Qingyu
Beginner
577 Views

Hi,

I'm encountering significant lagging with IP camera with build inference engine sample for age, emotion and gender recognition models.

It will freeze the terminal most of the time.

My input is "-i rtsp:username:password@ipv4:port/video_path". Tried to scaled down the resolution, didn't see much improvement.

However it works a lot better with USB camera.

Any comments would be highly appreciated.

Reply