How do I split my 800x480 5-inch screen into 2 parts

╄→尐↘猪︶ㄣ 提交于 2020-04-18 05:42:15

问题


I am building a stand-alone VR headset using Raspberry Pi 3 model b. I am having a problem with splitting the screen as we see on our phone. I am still learning Python so I don't have much idea on how to do this.

Here in this code, I have tried to solve the above-mentioned problem but when I run this code on Raspbian an error occurs that ImageGrab function works only on Windows and Mac. I tried to use pyscreenshot module also, although it works on my PC screen fairly when I connect it with my 5-inch screen, a black window opens and I see nothing.

import numpy as np
from PIL import ImageGrab
import cv2
import time

while(True):
screen = np.array(ImageGrab.grab(bbox=(920,420,1320,900)))
frame = cv2.cvtColor(screen, cv2.COLOR_BGR2RGB)
frame = cv2.resize(frame, (0, 0), None, 1, .83)
numpy_horizontal = np.hstack((frame,frame))
#cv2.namedWindow("window", cv2.WND_PROP_FULLSCREEN)
#cv2.setWindowProperty("window", cv2.WND_PROP_FULLSCREEN, cv2.WINDOW_FULLSCREEN)
cv2.imshow('window',numpy_horizontal)

if cv2.waitKey(25) & 0xFF == ord('q'):
    cv2.destroyAllWindows()
    break

回答1:


Your problem is not splitting a screen, but to display an image on the screen. So you need a library to do that. In your example you are using OpenCV. This is usually a bad choice and only usefull for some simple debugging. You need a proper GUI library.

Here you have a gazillion of options. If you are into games, I would look into moderngl and moderngl-window. This is based on PySide2, and as far as I have seen Raspberry Pi now supports this.



来源:https://stackoverflow.com/questions/60832485/how-do-i-split-my-800x480-5-inch-screen-into-2-parts-for-making-vr-headset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!