How to show images in split window in OpenCV

A typical scenario in computer vision is to show multiple images in different parts of a single window, like a split window. However, OpenCV can only display a single cv::Mat in a single window using cv::imshow(). So, to achieve what we want, we create a single cv::Mat whose size is equal to the window. We copy our multiple images into this mat at the locations we want and just display the big mat.

(Note that this is far easier than the ROI regions you would need to use with IplImage.)

This sample illustrates showing two 640x480 images side-by-side in a single window:

// 640x480 images
cv::Mat mat_1;
cv::Mat mat_2;

// Create 1280x480 mat for window
cv::Mat win_mat(cv::Size(1280, 480), CV_8UC3);

// Copy small images into big mat
mat_1.copyTo(win_mat(cv::Rect(  0, 0, 640, 480)));
mat_2.copyTo(win_mat(cv::Rect(640, 0, 640, 480)));

// Display big mat
cv::imshow("Images", win_mat);

Tried with: OpenCV 2.4.8 and Ubuntu 14.04

How to split in Byobu

By default, Byobu lets its terminal windows occupy all the available real estate. Sometimes, it is convenient to have two shell sessions in Byobu that are side-by-side. This is possible in Byobu by creating a vertical split or a horizontal split.

This splits the current window into two vertically or horizontally. In a vertical split, the current session is maintained in the left split, while a new shell session is opened in the right split. In a horizontal split, the current session is maintained in the top split, while a new session is opened in the bottom split.

The keyboard shortcuts for creating and switching between splits:

  • Ctrl + F2: Create a vertical split
  • Shift + F2: Create a horizontal split
  • Shift + F3 and Shift + F4: Switch forward and backward between the splits

You can see these keyboard shortcuts defined in the /usr/share/byobu/keybindings/f-keys.tmux file. You can override or change them in your own ~/.byobu/keybindings.tmux file.

Tried with: Byobu 5.106, Tmux 2.1 and Ubuntu 16.04 LTS

Floating windows of Visual Studio 2010

A cool feature of Visual Studio 2010 is that any window displayed in the IDE can be pulled out of the IDE as an independent floating window! Just click on the tab of the window and drag it out of the IDE. The window becomes undocked from the IDE and will now behave like an independent window.

I find it useful to use this trick along with the Windows 7 snap feature to have side-by-side code windows for comparison or collaboration. You can also pull a code window into another display in a multiple display setup. You are not limited to code windows, any other window in the IDE: solution explorer, output, call stack, or anything else can be pulled out. To dock back a floating window into the IDE, drag it back into the IDE space using its tab.

This feature is a huge leap over the older tiling and splitting methods of Visual Studio, which were quite onerous.

Reference: How to: Arrange and Dock Windows.

How to split window in Eclipse

I like working with split editor windows when comparing code from 2 different sections of a file or different files. This is easy to do in Visual Studio (see here). It is just as easy in Eclipse too, though not obvious if you merely look through the menus.

[ To split a window, just grab hold of a tab and pull it to the side until it turns into a black arrow. ]

[ Leave it and it turns into a new window with a new tab group. ]

To have split windows with the same file: Choose Window β†’ New Editor. That creates a new tab of the open file. Pull that tab as above to split the window.

For a horizontal split, pull the tab to the bottom of the window.

Keyboard shortcut for horizontal split: Ctrl+Shift+_
Keyboard shortcut for vertical split: Ctrl+Shift+{

Tried with: Eclipse Luna 4.4.1 and Ubuntu 14.04