C++ 取 OpenCV 窗口并全屏显示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5576944/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Take OpenCV window and make full screen
提问by Tubbs
I am currently making an OpenCV project in C++ where I look for motion with a kinect and use that to cue a slideshow (sans recognition). Currently, I am displaying the slideshow using OpenCV (as I've only had about a week to whip this up). It looks good and its quick. The only problem is that this is going to be on display for a big production and I can't really afford to have the window showing (I'm talking window decorations like the title bar and such).
我目前正在用 C++ 制作一个 OpenCV 项目,我在其中使用 kinect 寻找运动并使用它来提示幻灯片放映(无识别)。目前,我正在使用 OpenCV 显示幻灯片(因为我只有大约一周的时间来完成)。它看起来不错而且速度很快。唯一的问题是,这将在大型制作中展出,而我真的负担不起让窗口显示的费用(我说的是标题栏等窗口装饰)。
I need to get rid of the title bar. I've done a lot of research, and I have found out that you can magically grab the window handle by calling cvGetWindowHandle("SlideShow"), but that is a void function, so I don't really know how I am supposed to get a handle from that to manipulate.
我需要摆脱标题栏。我做了很多研究,我发现你可以通过调用 cvGetWindowHandle("SlideShow") 神奇地抓住窗口句柄,但这是一个空函数,所以我真的不知道我应该怎么做从中获取一个句柄进行操作。
I'm developing this for both windows AND ubuntu, since it will end up on a windows machine, but I can only demo on a laptop running ubuntu.
我正在为 windows 和 ubuntu 开发这个,因为它最终会在 windows 机器上,但我只能在运行 ubuntu 的笔记本电脑上进行演示。
If anyone can tell me how to take the window and render it fullscreen with a resized image to fill most if not the entire screen in either Windows or Ubuntu, I will be forever grateful.
如果有人能告诉我如何获取窗口并使用调整大小的图像将其全屏渲染以填充 Windows 或 Ubuntu 中的大部分(如果不是整个屏幕),我将永远感激不尽。
回答by Aras
I am using OpenCV 2.1 on Ubuntu 11.04. On my system CV_WINDOW_FULLSCREEN and CV_WINDOW_AUTOSIZE flags both map to 1 And both flags behave exactly the same. They give you a fixed size window, which would be expected for AUTOSIZE flag but not the FULLSCREEN. I think these two flags are meant for different functions although their simillar appearance is very confusing. The flag CV_WINDOW_NORMAL maps to value 0 which is what you have used. It gives you a resizable window that you could maximize, but it is not a fullscreen window.
我在 Ubuntu 11.04 上使用 OpenCV 2.1。在我的系统上, CV_WINDOW_FULLSCREEN 和 CV_WINDOW_AUTOSIZE 标志都映射到 1 并且两个标志的行为完全相同。它们为您提供了一个固定大小的窗口,这对于 AUTOSIZE 标志是预期的,但对于 FULLSCREEN 则不是。我认为这两个标志用于不同的功能,尽管它们的相似外观非常令人困惑。标志 CV_WINDOW_NORMAL 映射到您使用的值 0。它为您提供了一个可以最大化的可调整大小的窗口,但它不是全屏窗口。
Edit: I just found the solution in another stachoverflow post. Here is the solution from that post which worked great on my system:
编辑:我刚刚在另一个 stachoverflow 帖子中找到了解决方案。这是该帖子中的解决方案,它在我的系统上运行良好:
cvNamedWindow("Name", CV_WINDOW_NORMAL);
cvSetWindowProperty("Name", CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
cvShowImage("Name", your_image);
I get a real fullscreen with no title bar etc.
我得到了一个真正的全屏,没有标题栏等。
回答by cordellcp3
you can use the cv::setWindowProperty function for your purpose, just set it to CV_WINDOW_FULLSCREEN.
您可以将 cv::setWindowProperty 函数用于您的目的,只需将其设置为 CV_WINDOW_FULLSCREEN。
Full documentation in the openCV-WIKI
openCV-WIKI中的完整文档