How to save and finish python code?

Asked

Viewed 110 times

0

I’m using a camera to capture video, and save the video. I’m trying to save and finish the code with a command in the IDLE(python) but I’m not getting it.

Actualement to finish and save the program is necessary to be with the window open and press the letter "q" or "Q"...

This is my current code:

import cv2

camera = 0
camera1 = cv2.VideoCapture(camera)

while True:
    ret, frame = camera1.read()

#Sai do while caso a tecla apertada for "q" ou "Q"
    if cv2.waitKey(1) in (ord('q'),ord("Q")): 
        break

camera1.release()
cv2.destroyAllWindows()
print("FINALIZADO!")
  • 1

    But pressing the letter Q does not do what you need? It is not clear what you want to do.

  • I wanted to then hide the window, view the camera... and still the code work, and press a key and save the video.

  • In this code, use the Videowriter, and then put the release in def close(event): and within the if event.key == 'ctrl+c':

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.