I am trying to create a fullscreen opencv window (size 1920x1080) which should show an image (620x365) in mid center position of the opencv window. Unfortunately, the image gets expanded to fullscreen as well. How could this be done? Which properties need to be set? I am using opencv version 2.4.12.
import cv2
imgwindow = 'show my image'
image = cv2.imread('./myimage.jpg')
cv2.namedWindow(imgwindow, cv2.WINDOW_NORMAL)
cv2.setWindowProperty(imgwindow, cv2.WND_PROP_FULLSCREEN, cv2.cv.CV_CAP_PROP_FORMAT)
cv2.imshow(imgwindow,image)
cv2.waitKey(0)
cv2.destroyAllWindows()
when I use the following example, I get a full screen opencv window and a true size image but in the upper left corner of the window instead of mid-center position.
import cv2
import win32gui
import win32con
import ctypes
user32 = ctypes.windll.user32
winW, winH = [user32.GetSystemMetrics(0), user32.GetSystemMetrics(1)]
imgwindow = 'show my image'
image = cv2.imread('./myimage.jpg')
cv2.namedWindow(imgwindow, cv2.WINDOW_AUTOSIZE)
cv2.cv.CV_WINDOW_FULLSCREEN)
cv2.imshow(imgwindow,image)
simHndl = win32gui.GetForegroundWindow()
win32gui.MoveWindow(simHndl, 0,0, winW, winH, win32con.TRUE)
cv2.waitKey(0)
cv2.destroyAllWindows()
This is the example picture when the window contains the true image picture and is placed mid-center:
This is the example picture when the window is fullscreen but the image is expanded to full screen as well:
And this is the situation I am looking for: a fullscreen window and the true size image placed mid-center:


