Use a camera with multiple scripts

I have a camera and two separate scripts, one is facial recognition and the other is object recognition. I would like to run both of them at the same time with the same camera and by separate files, is it possible?

I have searched the internet and what I get the most is to use two cameras with a single script and not the other way around.

depends on the API and operating system. some OSes negotiate when multiple programs want data from the same camera (possibly for different resolutions and frame rates). other OSes/APIs don’t do that.

I think Apple is one of those that allows multiple consumers.

I think a “virtual webcam”, as used with OBS Studio, on Windows at least, allows multiple consumers.

if you need this regardless, you need to make something that accesses the webcam and distributes the data to the consumers, via some means of Inter-Process Communication (IPC). probably usable: ZeroMQ with the python module that conveniently wraps numpy arrays.

1 Like

You mean to use Socket? Transmit it locally and capture the frames from various clients, is that possible?