虚拟机python画图框怎么显示全部_用python和opencv显示完整图像时显示白色边框

I want to display a black image full screen, i have created even a black image with the same resolution of the screen.

But i get a little white stripe on top and on the left of the screen.

I don't know if it is a problem of my screen that is not aligned or its my code. I have tried in 2 displays and the white stripe is displayed.

So if you run this code below, do you get a full black image?

import numpy as np

import cv2

if __name__ == "__main__":

img = cv2.imread('nero.jpg')

cv2.namedWindow("test", cv2.WND_PROP_FULLSCREEN)

cv2.setWindowProperty("test", cv2.WND_PROP_FULLSCREEN, cv2.cv.CV_WINDOW_FULLSCREEN)

cv2.imshow("test",img)

cv2.waitKey(0)

cv2.destroyAllWindows()

EDIT :

This method is not working for me. do you know anther way or libraries to display a full screen image?

EDIT 2: still unsolved, i am starting to think that it is an openCv bug

解决方案

I have the same problem, there is a white stripe of 1 pixel on the left and on the top side of the window. Tested it with multiple monitors. OpenCV version 3.4.2

But there is a workaround which works perfectly fine in my case (see also https://gist.github.com/goraj/a2916da98806e30423d27671cfee21b6). Here's the code:

import cv2

import win32api

import win32gui

cv2.namedWindow("fullScreen", cv2.WINDOW_FREERATIO)

cv2.setWindowProperty("fullScreen",cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)

hwndMain = win32gui.FindWindow(None, "fullScreen")

rgb = win32gui.CreateSolidBrush(win32api.RGB(0, 0, 0))

GCLP_HBRBACKGROUND = -10

win32api.SetClassLong(hwndMain, GCLP_HBRBACKGROUND, rgb)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值