Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

sharing a numpy array between two running python programs on the same computer

I have two opencv2/Python scripts running at the same time on the same computer.

1) a streaming server script, 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 camera at once, so I need a way of passing/sharing each frame gathered to the other script.

They both grab the frame from the camera using rc,img = capture.read(); 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 about 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.

What would the best approach be to passing a numpy array between two running python programs on the same computer, and could someone kindly provide me some example code?