Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV window in fullscreen and without any borders

In OpenCV when displaying an image with:

cvSetWindowProperty("displayCVWindow", CV_WND_PROP_FULLSCREEN, 
CV_WINDOW_FULLSCREEN);

There is a small border around the full screened window if anyone ever noticed. Is there a way to get a rid of this?

Screenshot showing border of window when in full screen mode. Note: the screenshot was cropped to show only top-left corner

Screenshot showing border of window when in full screen mode. **Note**: the screenshot was cropped to show only top-left corner

like image 964
dr_rk Avatar asked Feb 25 '12 18:02

dr_rk


2 Answers

OpenCV does not provide this capability.

If you want to have the image in fullscreen mode or floating around without window/borders you will have 2 choices:

  • Hack the window created by OpenCV;

  • Create the window yourself using native API calls.

If you decide to hack the window, you may try this code and replace the SetWindowLong() call for:

SetWindowLong(win_handle, GWL_STYLE, 0;

If that doesn't work, you'll have to dig a little deeper into window creation on Windows.

like image 67
karlphillip Avatar answered Oct 23 '22 03:10

karlphillip


The problem is actually not the presence of a border, but the window's background showing through for some reason. From what I understand, OpenCV's namedWindow actually creates a two windows, one inside the other. The "white lines" are actually the grey background of the parent window. The fix I used was to change the background colour to the colour of the Mat I was displaying through the Windows API.

Here's the code I used to fix it:

cv::namedWindow("mainWin", WINDOW_NORMAL);//create new window
cv::setWindowProperty("mainWin",CV_WND_PROP_FULLSCREEN,CV_WINDOW_FULLSCREEN);//set fullscreen property
HWND hwnd = FindWindow(0, L"mainWin");//get window through Windows API
SetClassLongPtr(hwnd, GCLP_HBRBACKGROUND, (LONG) CreateSolidBrush(RGB(0, 0, 0)));//set window background to black; you can change the colour in the RGB()
like image 1
Samson Tan Avatar answered Oct 23 '22 01:10

Samson Tan