Coding a program and using pygame as an interface. Wanted to display a live stream from the laptop webcam on half the screen, but every time I run my code shell restarts. This is my code:
import pygame
import pygame.camera
pygame.init()
gameDisplay = pygame.display.set_mode((1280,720), pygame.RESIZABLE)
pygame.camera.init()
cam = pygame.camera.Camera(0,(1280,720))
cam.start()
while True:
img = cam.get_image()
gameDisplay.blit(img,(0,0))
pygame.display.update()
for event in pygame.event.get() :
if event.type == pygame.QUIT :
cam.stop()
pygame.quit()
exit()
The pygame shell shows a black screen for a second and then crashes, the python shell reads this:
= RESTART: C:/Users/micha/OneDrive/SCHOOL/A level material/Computer Science/The Project/pygameTest.py pygame 2.1.2 (SDL 2.0.18, Python 3.9.1) Hello from the pygame community. https://www.pygame.org/contribute.html
================================ RESTART: Shell ================================
Help would be greatly appreciated