Day051 — hide the top and left white lines in fullscreen in OpenCV
I want to display an image in full screen using OpenCV. I am coding with cpp.
Here is the GitHub repos I upload my code about this project:
To start
I found that these lines of code do the trick.
namedWindow("Display window", CV_WINDOW_NORMAL);
cvSetWindowProperty("Display window", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
imshow("Display window", image);
However, there are white lines on the top and left of the image.
To remove those lines, I have to comment out four lines of code in OpenCV and then recompiled it.
Original code:
/* Calculatess the window coordinates relative to the upper left corner of the mainhWnd window */
static RECT icvCalcWindowRect( CvWindow* window )
{
const int gutter = 1;
RECT crect, trect, rect; assert(window); GetClientRect(window->frame, &crect);
if(window->toolbar.toolbar)
{
GetWindowRect(window->toolbar.toolbar, &trect);
icvScreenToClient(window->frame, &trect);
SubtractRect( &rect, &crect, &trect);
}
else
rect = crect; rect.top += gutter;
rect.left += gutter;
rect.bottom -= gutter;
rect.right -= gutter; return rect;
}
The lines of code to be commented out:
//rect.top += gutter;
//rect.left += gutter;
//rect.bottom -= gutter;
//rect.right -= gutter;
Recompile OpenCV in Windows
The compile from source process is actually fairly simple. It just takes some time. I used CMake to do the compile and leave all configuration by default.
Result image:
After dealing with the white lines, you will be needed to hide the cursor. Also, I want the fullscreen window to appear on my second monitor. I found that both tasks will cost more time than I am willing to give so I give up at this point. I don’t want to spend another afternoon to do a seemingly simple task if a well-written image visualization library is used.
To conclude, I don’t recommend to use OpenCV to display images in full screen. It is just too much hustle to be dealt with.
reference website: