streaming_over_network_with_opencv_et_zeromq
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| streaming_over_network_with_opencv_et_zeromq [2022/02/18 12:48] – créée 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===== | ||
| + | **[[https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | =====Ressources===== | ||
| + | * **[[https:// | ||
| + | * **[[https:// | ||
| + | * https:// | ||
| + | * [[https:// | ||
| + | |||
| + | =====Implémentation dans Pure Data===== | ||
| + | * https:// | ||
| + | |||
| + | ====Installation de puredata==== | ||
| + | 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 to send audio blocks | ||
| + | ** 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 | ||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | sudo apt install python3-pip | ||
| + | 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:// | ||
| + | ====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 en python sur OpenCV, et qui a quelques bugs. On peut s'en passer facilement, il suffit de lire la doc OpenCV, par exemple pour retailler les images, les convertir en jpg etc ... | ||
| + | |||
| + | <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 | ||
| + | </ | ||
| + | |||
| + | <file python receiver_cam.py> | ||
| + | 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> | ||
streaming_over_network_with_opencv_et_zeromq.1645188519.txt.gz · Dernière modification : de serge
