This is a simple client-server application for object detection.
The server receives a video stream from the client through a websocket, processes it using YOLOv3, and returns the number of detected objects and their respective position for each frame.
- Python 3
-
Clone the repo and install the required Python packages.
git clone https://github.com/PedroDSFerreira/video-object-detection.git cd video-object-detection pip install -r requirements.txt
-
Open a terminal and navigate to the server directory.
cd server -
Download the YOLOv3 model files and place them in the
yolodirectory.wget https://pjreddie.com/media/files/yolov3.weights -P yolo
-
Run the server script.
python main.py --h <host_ip> --p <host_port> --o <object> --conf <conf_thresh> --nms <nms_thresh>
<host_ip>: Host ip (default: 127.0.0.1)<host_port>: Host port (default: 8080)<object>: Object to detect (default: person)<conf_thresh>: Confidence threshold (default: 0.6)<nms_thresh>: Non-maximum suppression threshold (default: 0.3)
The list of available objects can be found at server/yolo/coco.names
The server will start listening for incoming connections on the specified port.
-
Pull the Docker image.
-
Run the Docker container.
docker run -p <host_port>:8080 ghcr.io/pedrodsferreira/object-detection-server
If you want to run the server in an OSM cluster, after you already have the OSM cluster up and running, just run the following commands:
For adding the packages to OSM:
osm nfpkg-create cnf/object_detection_cnf/
osm nspkg-create cnf/object_detection_cnf_ns/For running the server in the cluster:
osm ns-create --ns_name object_detection_cnf_ns --nsd_name object_detection_cnf_nsd --vim_account <cluster-vim-name-or-id>-
Open a terminal and navigate to the client directory.
cd client -
Run the client script.
python main.py --h <host_ip> --p <host_port>
The client will establish a connection with the server and start sending video frames. The server will process each frame and return the number of detected objects and positions to the client.
- The YOLO model configuration file (
yolov3.cfg), weights file (yolov3.weights), and class names file (coco.names) should be placed in theyolodirectory.
Feel free to experiment with server/main.py input parameters to optimize object detection based on your specific use case.
- YOLOv3 model files: YOLOv3 Official Website
- COCO class names file: COCO Official Website
This project is licensed under the MIT License.
