Monday, September 12, 2022

Read IP CAM Video Stream using Python

 Most of IP CAM like Dahua support RTSP protocol, Connect your IP cam to the network and get the camera IP.

Prerequisites:
1- Camera Feed must be H.264 and can't be H.265
2- Camera Feed Bit Rate should be 4096 or lower

SAMPLE IP CAM Admin Panel



Expected RTSP URL will be like this 

Dahua Main Stream:
rtsp://admin:password@192.168.1.102:554/cam/realmonitor?channel=1&subtype=0

Dahua Sub Stream:
rtsp://admin:password@192.168.1.102:554/cam/realmonitor?channel=1&subtype=1


Then you can access it using VLC or Python script like this


How to install open CV?

there are four OpenCV packages that are pip-installable on the PyPI repository:

opencv-python: This repository contains just the main modules of the OpenCV library. If you’re a PyImageSearch reader, you do not want to install this package.

opencv-contrib-python: The opencv-contrib-python repository contains both the main modules along with the contrib modules. This is the library we recommend you install, as it includes all OpenCV functionality.

opencv-python-headless: Same as opencv-python but no GUI functionality. Useful for headless systems.

opencv-contrib-python-headless: Same as opencv-contrib-python but no GUI functionality. Useful for headless systems.

You DO NOT want to install both opencv-python and opencv-contrib-python. Pick ONE of them.

pip install opencv-contrib-python will install the next package 
 opencv_contrib_python-4.6.0.66-cp36-abi3-win_amd64.whl

No comments: