0

I am using the raspberry pi NOIR board to supply a Python motion detection script. This "motion detection script" uses opencv2 to grab, modify and detect motion.

I wanted to extend the motion detection script, by adding a continuous live feed, within the motion detection script, but have run into problems.

The problem I have, is I cannot have the two operations accessing the NOIR camera board together, because this upsets the PI.

1) Is it some how possible to have two scripts grabbing frames together using the below code in each?

capture = cv2.VideoCapture(0)
rc,img = capture.read()

2) Is it possible to modify the server script to incorporate the CV2 motion detection stuff, and have it continually detecting motion, regardless of the state of the server?

3) If I have two scripts, and only have the motion detection script grabbing a img (numpy array), how could I pass this img to the server script for display over the web?

I hope I've made myself clearer...

  • It's called IPC; one such method that could be applied here is memory-mapping. You could also use threads, which would probably be the most conventional route, although if "cannot have the two operations...together" means you need two separate processes for some reason, threads may not fulfill that. I hope there is not an XY problem here, this might be more challenging than it first appears ;) – goldilocks May 18 '15 at 14:22
  • Wait, so you are saying you have another script (not the one you linked to) that is also trying to access the camrera, right? – IronManMark20 May 18 '15 at 18:52
  • Hope my rewording has cleared things up. – reggie May 21 '15 at 10:19
  • I think this link can help you to use an intermedia v4l2loopback virtual device – mpromonet Jan 16 '16 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.