Reputation: 507
I'm running opencv version 3.1.0 and python 2.7 on Mac OSX 10.9 and want to display a black image on fullscreen. My screen's resolution is 2880x1800.
However when I attempt to do so, there is a large white border on the top of the screen.
Here's my code, note that black.jpg is a 2880x1800 image.
import cv2
img = cv2.imread("black.jpg")
cv2.namedWindow("window", cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty("window",cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)
cv2.imshow("window", img)
while True:
key = cv2.waitKey(20)
#exit on ESC
if key == 27:
break
I've also tried to just create a black image manually, using the following code.
import cv2
import numpy as np
img = np.zeros((1800, 2880))
cv2.namedWindow("window", cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty("window", cv2.WND_PROP_FULLSCREEN,cv2.WINDOW_FULLSCREEN)
cv2.imshow("window",img)
cv2.waitKey(0)
I've adjusted the dimensions of the numpy array to make it larger but the border still remains.
Doing some research I've discovered that this may be a bug with opencv. However the solutions only apply to windows operating systems, see the following:
OpenCV window in fullscreen and without any borders
and
How to display an image in full screen borderless window in openCV
If anyone has an idea of how to fix the bug for Macs I can go ahead and rebuild the library. Or if I am doing something incorrectly please let me know. Thanks!
Upvotes: 2
Views: 5631
Reputation: 330
I guess the key is to adapt the image size to the REAL macbook screen resolution. 1800x2880 probably is not the one you are currently adopting.
Code with OpenCV
import cv2
def show_full_screen_image():
while True:
print 'loading images...'
img = cv2.imread('preferred_image.png')
# Note: 900x1440 is the resolution with my MBP
img = cv2.resize(img, (1440, 900), interpolation=cv2.INTER_CUBIC)
cv2.namedWindow("test", cv2.WND_PROP_FULLSCREEN)
cv2.setWindowProperty("test", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
cv2.imshow("test", img)
key=cv2.waitKey(0)
if key==27: # ESC to exit
break
if __name__ == '__main__':
show_full_screen_image()
Upvotes: 1
Reputation: 21
The problem in those links is 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. You might be facing the same problem in OSX since openCV creates windows this way.
I solved it in windows by changing the background colour of the parent window through the Windows API, maybe you can try something similar in OSX.
Upvotes: 0