OpenCV—全屏显示

Opencv从初级到高级全套学习视频–提取码:x3t1
在播放视频或需要实时展示时,使用全屏的几率很大,OpenCV现在越来越强大已经支持全屏显示,而不需要在程序中再编写Windows函数,使用起来真是十分方便。

主要依靠Qt New Functions:

setWindowProperty(const string& winname, int prop_id, double prop_value) 

Parameters:	
name – Name of the window.
prop_id –
Window property to edit. The following operation flags are available:

CV_WND_PROP_FULLSCREEN Change if the window is fullscreen ( CV_WINDOW_NORMAL or CV_WINDOW_FULLSCREEN ).
CV_WND_PROP_AUTOSIZE Change if the window is resizable (CV_WINDOW_NORMAL or CV_WINDOW_AUTOSIZE ).
CV_WND_PROP_ASPECTRATIO Change if the aspect ratio of the image is preserved ( CV_WINDOW_FREERATIO or CV_WINDOW_KEEPRATIO ).
prop_value –
New value of the window property. The following operation flags are available:

CV_WINDOW_NORMAL Change the window to normal size or make the window resizable.
CV_WINDOW_AUTOSIZE Constrain the size by the displayed image. The window is not resizable.
CV_WINDOW_FULLSCREEN Change the window to fullscreen.
CV_WINDOW_FREERATIO Make the window resizable without any ratio constraints.
CV_WINDOW_KEEPRATIO Make the window resizable, but preserve the proportions of the displayed image.

因此调用全屏,仅仅需要,且不用重新cmake

namedWindow("FullScreen",CV_WINDOW_NORMAL);
setWindowProperty("FullScreen", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN );

(Qt New Functions中其他函数:displayOverlay,displayStatusBar,fontQt,addText……)

测试程序:

#include 
#include 
 
using namespace cv;
using namespace std;
 
int main()
{
	Mat src = imread("E:/Material/Img/Heads/01.jpg",1);
	imshow("src",src);
	namedWindow("FullScreen",CV_WINDOW_NORMAL);
	setWindowProperty("FullScreen", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN );
 
	//需要重新编译OpenCV Support Qt
	//displayOverlay("FullScreen","overlay");
	//displayStatusBar("FullScreen","statusBar",10);
 
	imshow("FullScreen",src);
	waitKey();
}

你可能感兴趣的:(OpenCV—全屏显示)