Opencv——全屏显示图片

本文介绍如何使用OpenCV库实现窗口全屏显示图片的功能。通过具体的C++代码示例,展示了创建窗口、设置窗口属性为全屏以及展示图片的过程。

原型 C++: void 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 );


/*********************************************
*opencv可以设置全屏显示图片,具体代码如下
**********************************************/
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace std;
using namespace cv;

int main()
{
	Mat srcImage = imread("pic.jpg",2|4);
	if (srcImage.empty())
	{
		cout << "srcImage load error\n" << endl;
		system("pause");
		exit(-1);
	}
	namedWindow("srcImage",CV_WINDOW_NORMAL);
	setWindowProperty("srcImage", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
	imshow("srcImage",srcImage);
	waitKey(0);
}



评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值