¡Tengo un pequeño problema extraño aquí!
Tengo un video en un archivo. Quiero extraer algunos fotogramas de este video y hacer un video de este y luego usarlo para mostrar (Nota: no quiero usar imshow () para esto). Y quiero hacer esto sin escribir esto en un archivo.
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
Cualquier sugerencia sería de gran ayuda!
Respuestas
1 para la respuesta № 1Crear un cap = cv2.VideoCapture(file_name)
. Obtén el ancho y la altura de tu película con
h = cap.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)
w = cap.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)
Crear una matriz numpy
frames = np.zeros((h, w, 3, number_of_frames), np.uint8)
y guarda los marcos que quieras mantener en esta matriz:
error, frame = cap.read()
frames[:,:,:,i] = frame
Si no sabes cuántos fotogramas tienes de antemano, simplemente concaténalos en una lista de Python.
Luego, muestra tus marcos.