+ // Find out how many cameras we have in the existing frames;
+ // if none, we start with a single camera.
+ num_cameras = 1;
+ {
+ lock_guard<mutex> lock(frame_mu);
+ for (size_t stream_idx = 1; stream_idx < MAX_STREAMS; ++stream_idx) {
+ if (!frames[stream_idx].empty()) {
+ num_cameras = stream_idx + 1;
+ }
+ }
+ }
+ change_num_cameras();
+}
+
+void MainWindow::change_num_cameras()
+{
+ assert(num_cameras >= displays.size()); // We only add, never remove.
+
+ // Make new display rows.
+ unsigned display_rows = (num_cameras + 1) / 2;