streaming_over_network_with_opencv_et_zeromq
Ceci est une ancienne révision du document !
Table des matières
Streaming over network with OpenCV et ZeroMQ
Z = Zero
M = Messaging
Q = Queuing
ZeroMQ
zeromq.org (également écrit ØMQ, 0MQ ou ZMQ) est une bibliothèque de messagerie asynchrone haute performance
Ressources
- Live video streaming over network with OpenCV and ImageZMQ FFMPEG ou GStreamer sont des options, mais c'est galère à implémenter.
- How to send OpenCV video footage over ZeroMQ sockets? sur stackoverflow.com
Installation
Dans un environnement virtuel python (3.9)
- requirements.txt
opencv-python imagezmq
sudo apt install python3-pip python3 -m pip install --upgrade pip sudo apt install python3-venv cd /le/dossier/de/votre/projet python3 -m venv mon_env source mon_env/bin/activate python3 -m pip install -r requirements.txt ou python3 -m pip install opencv-python imagezmq
Exemples simples
Caméra
Le principe est simple, sender envoie “image”, c'est une image en np.array
Cet array peut être définit par ce que vous voulez.
- sender_cam.py
import time import imagezmq import cv2 sender = imagezmq.ImageSender(connect_to='tcp://127.0.0.1:5555') my_name = "moi" cap = cv2.VideoCapture(2) time.sleep(2.0) while 1: # image peut venir de n'importe quoi ! # ici, c'est pour une caméra ret, image = cap.read() if ret: cv2.imshow("moi", image) sender.send_image(my_name, image) print("send:", image.shape) if cv2.waitKey(10) == 27: break
- receiver_cam.py
import cv2 import imagezmq image_hub = imagezmq.ImageHub() while 1: your_name, image = image_hub.recv_image() print(your_name, image.shape) cv2.imshow(your_name, image) image_hub.send_reply(b'OK') if cv2.waitKey(10) == 27: break
streaming_over_network_with_opencv_et_zeromq.1645259683.txt.gz · Dernière modification : 2022/02/19 08:34 de serge