Skip to content
Advertisement

Constant camera grabbing with OpenCV & Python multiprocessing

I’m after constantly reading images from an OpenCV camera in Python and reading from the main program the latest image. This is needed because of problematic HW.

After messing around with threads and getting a very low efficiency (duh!), I’d like to switch to multiprocessing.

Here’s the threading version:

JavaScript

And –

JavaScript

Can someone please help me translate this to multiprocess land ?

Thanks!

Advertisement

Answer

I’ve written several solutions to similar problems, but it’s been a little while so here we go:

I would use shared_memory as a buffer to read frames into, which can then be read by another process. My first inclination is to initialize the camera and read frames in the child process, because that seems like it would be a “set it and forget it” kind of thing.

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement