简体   繁体   English

Raspberry Pi 未按预期显示带有屏幕的 pygame

[英]Raspberry Pi not showing pygame with screen as expected

I am trying to get a Raspberry Pi 3B+ to show live streams from 3 cameras, using a screen to get multiple instances of omxplayer to run on the positions I want them.我正在尝试让Raspberry Pi 3B+显示来自 3 个摄像头的实时流,使用屏幕让omxplayer 的多个实例在我想要的位置上运行。 This works exactly as expected.这完全按预期工作。

The problem now is, that I want a static image in the last space on the screen.现在的问题是,我想要屏幕上最后一个空间中的静态图像。 For that I wanted to use pygame, so I later could have more fun in that area, and maybe not only have an image.为此,我想使用 pygame,这样我以后就可以在该领域获得更多乐趣,而且可能不仅有图像。

The problem now is how the image is positioned:现在的问题是如何定位图像:

https://imgur.com/mUQ38vV (the image is the same size as the video feeds, and I had expected it to be in the bottom right of the monitor, with a thin black line towards the feed above and to the right of it) https://imgur.com/mUQ38vV (图像与视频源的大小相同,我原以为它位于显示器的右下角,一条细黑线指向屏幕的上方和右侧的源它)

I expected the white square to be directly under the top left video feed, but there are large black borders.我希望白色方块直接位于左上角的视频源下方,但有大的黑色边框。

The Python code I use for showing the image is as follows:我用于显示图像的 Python 代码如下:

import time
import pygame

transform_x = 958 #648 #how wide to scale the jpg when replaying
transfrom_y = 539 #how high to scale the jpg when replaying
offset_x = 0 #how far off to left corner to display photos
offset_y = 540 #how far off to left corner to display photos

try:
    pygame.init()

    info = pygame.display.Info() # You have to call this before pygame.display.set_mode()
    screen_width,screen_height = info.current_w,info.current_h
    window_width,window_height = screen_width,screen_height

    screen = pygame.display.set_mode((window_width, window_height))
    #screen = pygame.display.set_mode((0,0))
    pygame.mouse.set_visible(False) #hide the mouse cursor  
    filename = "image.png"
    img=pygame.image.load(filename) 
    #img = pygame.transform.scale(img,(transform_x,transfrom_y))
    screen.blit(img,(offset_x,offset_y))
    pygame.display.flip() # update the display
    time.sleep(30) # pause
finally:
    pygame.quit()

I tried with pygame.FULLSCREEN and other modes, but none of them would go all the way to the edge of the monitor.我尝试过pygame.FULLSCREEN和其他模式,但它们都不会一直到显示器的边缘。

To show the picture I used this command:为了显示图片,我使用了这个命令:

sudo screen -dmS pic sh -c 'python pic.py'

Can anyone help me figure out what I am doing wrong here?谁能帮我弄清楚我在这里做错了什么?

So I got it fixed...所以我把它修好了...

I had to comment out disable_overscan=1 in /boot/config.txt ...我不得不在/boot/config.txt注释掉disable_overscan=1 ...

I didn't think of this, because omxplayer was at the positions I expected it to be..我没有想到这一点,因为 omxplayer 处于我预期的位置..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM