OpenCV window in fullscreen and without any borders

后端 未结 3 1666
情深已故
情深已故 2020-12-11 06:14

In OpenCV when displaying an image with:

cvSetWindowProperty(\"displayCVWindow\", CV_WND_PROP_FULLSCREEN, 
CV_WINDOW_FULLSCREEN);

There is

3条回答
  •  醉酒成梦
    2020-12-11 07:06

    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()
    

提交回复
热议问题