This is a project that displays streaming video from a USB camera or IP camera (RTSP) on the web. It uses Python 3.11.6 and at least version 8.17.0 of Node.js. Please ensure the required environments are installed before launching the project.
Follow the instructions below to set up and run the project on your local machine for development and testing purposes.
What things you need to install the software and how to install:
- NVM - To install node modules
- Node.js >= 8.17.0 - To build the web server
- Python >= 3.11.6 - To capture the camera stream
- Download and install NVM (nvm-setup.exe) on your local machine (for windows)
- Execute nvm-setup.exe and keep pressing Next until the installation is completed
- Open the Start menu, type Windows PowerShell, select Windows PowerShell, and then select Run as administrator.
- Enter the command in powershell:
nvm install 8.17.0
andnvm use v8.17.0
- Download and install Python 3
- Clone this project
git clone https://github.com/kim1037/opencv_py_to_nodejs.git
- Install all npm modules the project needs:
npm install
- Install python modules belows:
pip install requests pip install python-socketio pip install opencv-python
- Open the
opencv.py
Change the camera source to your configuration, you can use a built-in local camera0
, an external USB camera1 or 2
, or an RTSP URL.
cap = cv2.VideoCapture(0) # 0: use bulit-in webcam, 1 or 2: use USB webcam, or rtsp url
# cap = cv2.VideoCapture(rtsp://192.168.1.111/test2)
-
Run the node.js server
npm run dev
-
Preview Streaming Camera on web browser by go to this URL: 127.0.0.1:3000