streaming_over_network_with_opencv_et_zeromq
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
streaming_over_network_with_opencv_et_zeromq [2022/02/18 13:05] – serge | streaming_over_network_with_opencv_et_zeromq [2022/02/25 13:15] (Version actuelle) – [Profondeur d'une OAK-D Lite] serge | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== Streaming over network with OpenCV et ZeroMQ ====== | ====== Streaming over network with OpenCV et ZeroMQ ====== | ||
+ | <WRAP center round box 30%> | ||
+ | **Z = Zero\\ | ||
+ | M = Messaging\\ | ||
+ | Q = Queuing** | ||
+ | </ | ||
+ | **Pas de latence, peu ce consommation CPU, en python super facile à implémenter**\\ | ||
+ | **mais pas de réception dans VLC et Pure Data.**\\ | ||
+ | Utiliser **[[streamer_des_images_opencv_avec_v4l2-loopback|Streamer des images OpenCV avec v4l2-loopback]]** | ||
=====ZeroMQ===== | =====ZeroMQ===== | ||
**[[https:// | **[[https:// | ||
- | |||
* https:// | * https:// | ||
* https:// | * https:// | ||
+ | =====Ressources===== | ||
+ | * **[[https:// | ||
+ | * **[[https:// | ||
+ | * https:// | ||
+ | * [[https:// | ||
- | =====imageZMQ: Transporting OpenCV images===== | + | =====Implémentation dans Pure Data===== |
+ | * https:// | ||
- | https:// | + | ====Installation de puredata==== |
- | imageZMQ is a set of Python classes that transport OpenCV images from one computer | + | sudo apt install multimedia-puredata libzmq3-dev |
+ | |||
+ | ====Compilation du patch zmq==== | ||
+ | git clone git@github.com: | ||
+ | cd pd-zmq | ||
+ | make | ||
+ | |||
+ | ====Utilisation des scripts fournis==== | ||
+ | Ça envoie et reçoit des int/string, mais pas d' | ||
+ | Extrait de https:// | ||
+ | < | ||
+ | LATER | ||
+ | * proper architecture workflows | ||
+ | ** multiconnects/ | ||
+ | * complex objects | ||
+ | ** [zmf_router] -- [broker] as abstraction? | ||
+ | ** [zmf_dealer] -/ | ||
+ | ** [zmf_pair] | ||
+ | * implement streams | ||
+ | ** binary modes | ||
+ | * send/ | ||
+ | ** binary (for audio/video frames) | ||
+ | ** string (for communication w external programs) | ||
+ | </ | ||
+ | Le paquet de la première image est reçu, mais il ne passe passe rien ensuite ... | ||
+ | =====Installation du module python===== | ||
+ | Dans un environnement virtuel python (3.9) | ||
+ | <file text requirements.txt> | ||
+ | opencv-python | ||
+ | imagezmq | ||
+ | </ | ||
- | =====Ressources===== | + | <code bash> |
- | * **[[https://pyimagesearch.com/2019/04/15/live-video-streaming-over-network-with-opencv-and-imagezmq/|Live video streaming over network with OpenCV and ImageZMQ]]** L'utilisation de FFMPEG ou GStreamer | + | sudo apt install python3-pip |
- | * **[[https://stackoverflow.com/ | + | python3 -m pip install --upgrade pip |
+ | sudo apt install python3-venv | ||
+ | |||
+ | cd / | ||
+ | python3 -m venv mon_env | ||
+ | source mon_env/ | ||
+ | python3 -m pip install -r requirements.txt | ||
+ | ou | ||
+ | python3 -m pip install opencv-python imagezmq | ||
+ | </ | ||
+ | |||
+ | ====Lancement d'un script==== | ||
+ | |||
+ | cd / | ||
+ | ./ | ||
+ | |||
+ | ====Sender avec python et receive dans pd==== | ||
+ | |||
+ | Bon, là je suis nul en pd ! | ||
+ | =====Exemples===== | ||
+ | * Exemples inspirés de: https://github.com/jeffbass/imagezmq/tree/master/examples | ||
+ | ====Caméra==== | ||
+ | Le principe est simple, sender envoie " | ||
+ | Cet array peut être définit par ce que vous voulez.\\ | ||
+ | |||
+ | Les exemples utilisent souvent imutils, qui est une surcouche | ||
+ | |||
+ | <file python sender_cam.py> | ||
+ | import time | ||
+ | import imagezmq | ||
+ | import cv2 | ||
+ | |||
+ | sender = imagezmq.ImageSender(connect_to=' | ||
+ | my_name = " | ||
+ | cap = cv2.VideoCapture(2) | ||
+ | time.sleep(2.0) | ||
+ | while 1: | ||
+ | # image peut venir de n' | ||
+ | # ici, c'est pour une caméra | ||
+ | ret, image = cap.read() | ||
+ | if ret: | ||
+ | cv2.imshow(" | ||
+ | sender.send_image(my_name, | ||
+ | print(" | ||
+ | if cv2.waitKey(10) == 27: | ||
+ | break | ||
+ | </ | ||
- | https:// | + | < |
+ | import cv2 | ||
+ | import imagezmq | ||
+ | image_hub = imagezmq.ImageHub() | ||
+ | while 1: | ||
+ | your_name, image = image_hub.recv_image() | ||
+ | print(your_name, | ||
+ | cv2.imshow(your_name, | ||
+ | image_hub.send_reply(b' | ||
+ | if cv2.waitKey(10) == 27: | ||
+ | break | ||
+ | </ | ||
- | {{tag> | + | {{tag>zmc opencv pd pure-data pure_data python sb}} |
streaming_over_network_with_opencv_et_zeromq.1645189533.txt.gz · Dernière modification : 2022/02/18 13:05 de serge