Multiprocessing Images and Pipe comunication

359 Views Asked by At

I'm trying to speed up an imaging pipeline considering two processors.

  1. Take images and write it to a pipe
  2. read image and compute

Therefore, I've read something about pipes:

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()

Then I have a code snippet with two processes:

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

I want to get the images sent to the featureExtraction Processor as soon as one image is aquired. Therefore, I would like to use the pipe example from above. However, I wasn't able to get these two examples together. I would be thankful for some advice :) kind regards

0

There are 0 best solutions below