Sharing a numpy array between 2 running Python scripts
Posted: Fri Jun 05, 2015 11:31 am
I have two opencv2/Python scripts running at the same time on the same Raspberry PI.
1) A streaming server script based on https://github.com/berak/opencv_smallfr ... g_serve.py that outputs a live camera feed to the web
2) A motion detection script, that detects movement from a camera
Only one of these scripts can access the NOIR camera board at once, so I need a way of passing/sharing each frame gathered to the other script.
They both grab the frame from the NOIR camera board using opencv2's; so i'll have to remove that from one of them and somehow pass the img to the other script when rc is true.
As the camera frame rate is substantial (24f/s), I don't think it's feasible to save the img (numpy array) to a file on a disc that they can both access; but I may be wrong!
I've been scratching my head and searching the net for examples on scripts that pass data, but alas i'm stuck.
How could I share a numpy array (approximately a megabyte of data) between two running python programs on the same Raspberry PI, and could someone kindly provide me some example code?
1) A streaming server script based on https://github.com/berak/opencv_smallfr ... g_serve.py that outputs a live camera feed to the web
2) A motion detection script, that detects movement from a camera
Only one of these scripts can access the NOIR camera board at once, so I need a way of passing/sharing each frame gathered to the other script.
They both grab the frame from the NOIR camera board using opencv2's
Code: Select all
rc,img = capture.read()
As the camera frame rate is substantial (24f/s), I don't think it's feasible to save the img (numpy array) to a file on a disc that they can both access; but I may be wrong!
I've been scratching my head and searching the net for examples on scripts that pass data, but alas i'm stuck.
How could I share a numpy array (approximately a megabyte of data) between two running python programs on the same Raspberry PI, and could someone kindly provide me some example code?