全屏且无边框的 OpenCV 窗口
在 OpenCV 中显示图像时:
cvSetWindowProperty("displayCVWindow", CV_WND_PROP_FULLSCREEN,
CV_WINDOW_FULLSCREEN);
如果有人注意到,全屏窗口周围有一个小边框。有办法摆脱这个吗?
显示全屏模式下窗口边框的屏幕截图。 注意:屏幕截图被裁剪为仅显示左上角
In OpenCV when displaying an image with:
cvSetWindowProperty("displayCVWindow", CV_WND_PROP_FULLSCREEN,
CV_WINDOW_FULLSCREEN);
There is a small border around the full screened window if anyone ever noticed. Is there a way to get a rid of this?
Screenshot showing border of window when in full screen mode. Note: the screenshot was cropped to show only top-left corner
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
OpenCV 不提供此功能。
如果您想让图像处于全屏模式或在没有窗口/边框的情况下浮动,您将有 2 个选择:
破解创建的窗口by OpenCV;
使用本机 API 调用自行创建窗口。
如果您决定破解窗口,您可以尝试此代码并替换
SetWindowLong()
呼吁:如果这不起作用,您将不得不更深入地了解 Windows 上的窗口创建。
OpenCV does not provide this capability.
If you want to have the image in fullscreen mode or floating around without window/borders you will have 2 choices:
Hack the window created by OpenCV;
Create the window yourself using native API calls.
If you decide to hack the window, you may try this code and replace the
SetWindowLong()
call for:If that doesn't work, you'll have to dig a little deeper into window creation on Windows.
问题实际上不在于边框的存在,而是窗口的背景由于某种原因而显示出来。据我了解,OpenCV的namedWindow实际上创建了两个窗口,一个在另一个窗口内。 “白线”实际上是父窗口的灰色背景。我使用的修复方法是将背景颜色更改为我通过 Windows API 显示的 Mat 的颜色。
这是我用来修复它的代码:
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:
我遇到了这个问题,发现它很烦人,所以我做了一个小函数,它只是创建一个你喜欢的任何颜色的“框架”并将图像放在那里。不幸的是,由于我找不到可靠的跨平台方法来获取显示尺寸,因此您必须自己传递它们。这是代码:
I ran into this and found it annoying, so I make a small function which just creates a "frame" of whatever colour you like and puts the image in there. Unfortunately, since I counldn't find a reliable cross-platform way to get display-sizes, you have to pass them yourself. Here's the code: