多处理图像和管道通信

问题描述 投票:0回答:1

考虑到两个处理器,我正在尝试加速成像管道。

  1. 拍摄图像并将其写入管道
  2. 读取图像并计算

因此,我读过一些有关管道的内容:

import os 
from multiprocessing import Process, Pipe
import time
def ponger (p,s):
    msg = p.recv()
    print("Process{0} got message:{1}".format(os.getpid(),msg))
    time.sleep(1)
    p.send(s)


if __name__ == "__main__": 
    parent,child = Pipe()
    proc = Process(target = ponger, args = (child,"ping"))
    proc.start()
    parent.send("pong")
    ponger(parent,"pong")
    proc.join()

然后我有一个包含两个进程的代码片段:

if __name__ == '__main__':
    p_camera = Process(target = controlHardware,args = (SSHConnection,CameraInstance))
    p_featureExtraction = Process(target = processImage, args = ())

我想在获取一张图像后立即将图像发送到特征提取处理器。因此,我想使用上面的管道示例。 但是,我无法将这两个示例放在一起。我将不胜感激一些建议:)亲切的问候

python pipe multiprocessor
1个回答
0
投票

这个重播来得有点晚了。查看这个答案以获得见解。将图像转换为可以通过管道发送的内容,然后再将其转换回来。

© www.soinside.com 2019 - 2024. All rights reserved.