Does declaring and initializing a Mat inside a while loop create performance issues? For example mat2 inside the while loop? If so what would be a better approach?
that? not at all. that’s creating a view into the first Mat. that’s constant time effort. perfectly reasonable to do.
what you should be worried about is opening (and closing) a VideoCapture repeatedly. that is a tangible and serious waste of time. the capture device id is always 0 in your example.
Thank you! I did miss that Video Capture while creating the example, normally I keep it outside the while loop.