如何将800x480 5英寸屏幕分成两部分 [英] How do I split my 800x480 5-inch screen into 2 parts

查看:47
本文介绍了如何将800x480 5英寸屏幕分成两部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Raspberry Pi 3模型b构建独立的VR耳机.我在手机上看到屏幕拆分时遇到问题.我仍在学习Python,因此我对如何执行此操作没有太多了解.

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.

在此代码中,我试图解决上述问题,但是当我在Raspbian上运行此代码时,会出现一个错误,指出 ImageGrab 函数仅在Windows和Mac上有效.我也尝试使用pyscreenshot模块,尽管当我将其与5英寸屏幕连接时,它也可以在PC屏幕上正常工作,但会打开一个黑色窗口,但我什么也看不到.

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

推荐答案

您的问题不是拆分屏幕,而是在屏幕上显示图像.因此,您需要一个库来执行此操作.在您的示例中,您使用的是 OpenCV .这通常是一个错误的选择,并且仅对一些简单的调试有用.您需要一个适当的GUI库.

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.

在这里,您有无数的选择.如果您喜欢游戏,我会研究 moderngl moderngl-window .它基于PySide2,据我所知,Raspberry Pi现在支持此功能.

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.

这篇关于如何将800x480 5英寸屏幕分成两部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆