OpenCV window in fullscreen and without any borders
Solution 1
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:
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.
Solution 2
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()
Comments
-
dr_rk almost 2 years
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
-
dr_rk about 12 yearsYour suggestion:
SetWindowLong(win_handle, GWL_STYLE, 0)
almost works. The border on the right and bottom parts of the screen have now gone. There is still a very thin border on the left and top. Is it something to do with window position, you think? I triedSetWindowPos(win_handle, HWND_NOTOPMOST, x, y, w, h, flags);
, but it didnt help -
karlphillip about 12 yearsWell, this approach seems very limited. It's best to create a window from scratch. Another approach is to create a frameless OpenGL window as demonstrated here, and then send your image to the GPU for display.
-
Suuuehgi about 5 yearsFor Python use:
cv2.namedWindow(name, cv2.WND_PROP_FULLSCREEN) cv2.setWindowProperty(name, cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN) cv2.imshow(name, frame)