I've written a software in C++ for processing the video stream coming from a camera, using openCV libraries. I would like to save the video frame while processing it, in order to have the possibility to run the code many times offline using the exact same video as input. I was thinking to use multi-threading using the Producer/Consumer Pattern.
My idea would be to have one producer (frame grabber) and two consumer (one for processing the image and the second one for saving the frames on file (as video)).
I don't have experience with multi-threading programming, so I've searched for some tutorials on internet. All the tutorials I've found were about one producer and one consumer, but what I need is slightly different: my need would be a producer that sends the same image to both consumers and after both consumers finish their work, go ahead with the next frame. The point is that the producer would have one queue where it stores the frames, while the consumers both would need to read the same element once from the same queue.
Do you have any suggestion? Do you think that the pattern I've chosen fits my need?
Thanks.
Producer-consumer works. In your case, the producer could "produce" twice, first placing it in the processing queue, then placing a 2nd copy in the saving queue.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments