get paid

Get paid for the tasks you do online

2020年5月24日 星期日

利用 imagezmq 影像串流

imagezmq 套件 讓人輕易的可以將遠端的影像串流傳送到server 上

目前有一個專案 , 需要將 Tx2 上處理過的影像傳到 座位上以方便監控

使用 imagezmq 開發讓事情變得很間單

架構如下

Tx2 (imagezmq client) --> Server ( imagezmq server)

Client 端的 程式


#192.168.31.210 是 server (要接收串流的 IP 位置) 5555 是指定的 port .
 
sender = imagezmq.ImageSender(connect_to='tcp://192.168.31.210:5555')
 
rpi_name = socket.gethostname() # 抓取系統的名稱, 如果有多台裝置傳到 server 端 server 
才可以分辨 誰是誰

picam = VideoStream(usePiCamera=True).start()
 
time.sleep(2.0)  # allow camera sensor to warm up

while True:  # send images as stream until Ctrl-C
      image = picam.read() # 讀取 camera 的 frame
      sender.send_image(rpi_name, image) # 把影像送出



Server 端的程式

import cv2
import imagezmq
image_hub = imagezmq.ImageHub()
while True:  # show streamed images until Ctrl-C
  rpi_name, image = image_hub.recv_image()
  cv2.imshow(rpi_name, image) # 1 window for each RPi
  cv2.waitKey(1)
  image_hub.send_reply(b'OK')


有沒有很簡單

詳細內容可以參考
原作者的 git

https://github.com/jeffbass/imagezmq



沒有留言:

張貼留言

ChartGPT 學 python 很強喔

 ChartGPT 最近很紅 ,  前一陣子有一些小 module  本來想 google  一下 語法 但發現用 chartGPT 直接請他給 sample code 反而較快 所以只要你有基本 知識 ChartGPT 可以加速你的開發 好用喔