title: Share images and data between two python processes running simultaneously with multiprocessing
body: <p>I'm currently working on a python project. It's about image detection. I have to processes, which are running simultaneously with multiprocessing. The first function communicates with the frame grabber and is doing some image processing. The second function communicates with a neural net, which does the actual image-detection. The second function needs the image grabbed in the first function for the detection. The second function should then provide the results, which are used by the first function to draw rectangles on the video stream (where the detected objects are).</p>
  
  <p>The code looks something like this:</p>
  
  <pre><code>import multiprocessing
  import cv2
  import json
  
  def fun1():
  while True:
  # Shows video-stream, does image editing, grabs frames
  # and stores them in an external folder
  # Accesses the result for drawing rectangles from the
  # .json file
  
  def fun2():
  while True:
  # Uses frames from the external folder
  # does image-detection, saves result to .json file
  
  if __name__ == "__main__":
  s = Process(target=fun1)
  r = Process(target=fun2)
  s.start()
  r.start()
  s.join()
  r.join()
  </code></pre>
  
  <p>As you can see, both processes are running in an infinite while loop. As for now, I save the images created in fun1 in a folder, where fun2 can access them. The results from the neural net from fun2 are saved in a .json file, where fun1 can access them.</p>
  
  <p>Both, the result and the image, change every iteration. I was wondering, if there is a way to send the current image directly to fun2 and to send the result from fun2 to fun1 without using an extern .json file. Is there a way to communicate directly?</p>
  
  <p>I hope that I could explain my problem understandably.</p>
  
  <p>Thanks for helping me out!</p>