Ho un piccolo problema strano qui!
Ho un video in un file. Voglio estrarre alcuni fotogrammi da questo video e creare un video da questo e quindi usarlo per visualizzare (Nota: non voglio usare imshow () per questo). E voglio farlo senza scrivere questo in un file.
Algorithm:
1. Read the video from file
2. extract the frames
3. make a video out of these frames(save it as a variable; do not write it into a file)
4. Use this variable which holds the new video for displaying
Qualsiasi suggerimento sarebbe di grande aiuto!
risposte:
1 per risposta № 1Creare un cap = cv2.VideoCapture(file_name)
. Ottieni la larghezza e l'altezza del tuo film con
h = cap.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)
w = cap.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)
Crea una matrice numpy
frames = np.zeros((h, w, 3, number_of_frames), np.uint8)
e salva i frame che vuoi mantenere su questo array:
error, frame = cap.read()
frames[:,:,:,i] = frame
Se non sai quanti fotogrammi hai in precedenza, basta concatenarli in una lista Python.
Quindi, visualizza i tuoi frame.