Java VideoCapture properties not being considered. Need to avoid "while true" for latest frame. Multi-camera environment

Hi! I am trying to create e multi-camera software that uses OpenCV for RTSP video stream processing (both displaying and processing of specific frames). The issue I am having for the longest time is having to use a threaded while true for each camera whose only job is to “grab()” frames and then retrieve and process them in another thread. so that I always get the latest frame. This gets resource consuming very fast with multiple cameras. I have tried using the VideoIo properties, but they have no effect whatsoever. I am using opencv_java451, JavaFX11 and Java 15.
Is there a way to grab the latest frame without the need to have a while true thread for each camera? Or is there something I can do to have the properties considered so that the buffer size, or Pos_frames is considered?
If needed, I can provide further code examples, anything that someone needs to help me find a solution.
Thank you!

how many streams? what frame rate? what frame size?

how many frames do you actually need to process from all those received (what fraction)?

I’ll say you’re stuck and there’s no way around it but to decode all the streams.

Thanks for the reply! There can be any number of stream but as a good estimation we can say 10-15. Frame rate is on the cameras is 25 with the current config. Picture size is 2560x1440.
I need to process a frame every 200 milliseconds. That is retrieve it and save it somewhere for any number of processing.
I noticed that if I set the Pos_frames attribute to any number, the property will always be 0 and I will get the latest frame, but the thread will only do its job once every 2 seconds, no matter what period I set it to.
E.G.:

stream.set(Videoio.CAP_PROP_POS_FRAMES, 0);
stream.grab();
stream.retrieve(concurrentMatMap.get(imageView.getId()));

executorService.scheduleAtFixedRate(displayTask, streamInitialDelay, anyNumberSmallerThan2Seconds, TimeUnit.MILLISECONDS);

The code above will execute every 2 seconds at its fastest so instead of getting 10 frames every 2 seconds, I only get 1.

Maybe this can bring more details. Also, can feature requests or pull request be made to have something implemented in this direction in OpenCV?

Thanks again!

you can’t seek in streams. you can seek in video files but you don’t have files.

if you need one in five frames, perhaps consider reducing the frame rate at every source.

Thanks! We really wanted to avoid lowering the fps on the cameras but it seems as it’s the only way unfortunately… Thank you again!

10 - 15 streams, each 25 fps, each 2560x1440, that is 0.9 - 1.4 GIGAPIXELS per second. you gotta realize that some things might just be too much strain on your resources.

Indeed, but we would not need to use all 25 frames. That is why I wanted to execute a grab() every x milliseconds and skip the rest. Because that camera can be used by other apps which may need the higher fps and we would not be available to modify it.