Я новичок в программировании на Python и не могу менять фреймы с пользовательскими событиями.Рамки появляются и исчезают мгновенно, или я хочу захватить их и сохранить отображение.
try:
while True:
ret, frame = camera.read()
screen.fill([0,0,0])
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame = np.rot90(frame)
frame = pygame.surfarray.make_surface(frame)
screen.blit(frame, (0,0))
pygame.display.update()
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == pygame.K_a:
print ("a")
ret, frame = camera.read()
screen.fill([0,0,0])
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
frame = np.rot90(frame)
frame = pygame.surfarray.make_surface(frame)
screen.blit(frame, (0,0))
pygame.display.update()
if event.key == pygame.K_z:
print ("z")
ret, frame = camera.read()
screen.fill([0,0,0])
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
frame = np.rot90(frame)
frame = pygame.surfarray.make_surface(frame)
screen.blit(frame, (0,0))
pygame.display.update()
if event.key == pygame.K_ESCAPE:
sys.exit(0)
except (KeyboardInterrupt,SystemExit):
pygame.quit()
cv2.destroyAllWindows()