python实现全屏显示图片_用opencv+python全屏进行显示图片

# -*- coding: utf-8 -*-

"""

Created on Thu Jun 22 16:44:27 2017

@author: sakurai

"""

import numpy as np

import cv2

import screeninfo

if __name__ == '__main__':

screen_id = 2

is_color = False

# get the size of the screen

screen = screeninfo.get_monitors()[screen_id]

width, height = screen.width, screen.height

# create image

if is_color:

image = np.ones((height, width, 3), dtype=np.float32)

image[:10, :10] = 0 # black at top-left corner

image[height - 10:, :10] = [1, 0, 0] # blue at bottom-left

image[:10, width - 10:] = [0, 1, 0] # green at top-right

image[height - 10:, width - 10:] = [0, 0, 1] # red at bottom-right

else:

image = np.ones((height, width), dtype=np.float32)

image[0, 0] = 0 # top-left corner

image[height - 2, 0] = 0 # bottom-left

image[0, width - 2] = 0 # top-right

image[height - 2, width - 2] = 0 # bottom-right

window_name = 'projector'

cv2.namedWindow(window_name, cv2.WND_PROP_FULLSCREEN)

cv2.moveWindow(window_name, screen.x - 1, screen.y - 1)

cv2.setWindowProperty(window_name, cv2.WND_PROP_FULLSCREEN,

cv2.WINDOW_FULLSCREEN)

cv2.imshow(window_name, image)

cv2.waitKey()

cv2.destroyAllWindows()

原文:https://www.cnblogs.com/enumx/p/12342413.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值