Make a slideshow of images and control the time of this

0

I want to show different images and each one shows 5 seconds. For now I have tried the two options that have occurred to me,

  • With sleep
  • Doing a while loop that can not be exited until 5 seconds or more have passed. This second option is worse, since they are never exactly 5 seconds. It's not serious, but it's not exact.

The problem is that it only shows me the last photo and also only does it after those 5 seconds have elapsed. While I get empty sample window in gray.

I show code made for the second option. For both the same thing happens to me and the truth is that I do not know how to approach it.

import cv2
import numpy as np
import glob
from time import time

ruta = 'imagenes_progress/'
extension = '.jpg'

fotos = glob.glob('imagenes_progress/*.jpg')
total_fotos = len(fotos)

for x in range(1, total_fotos+1):
    elapsed_time = 0
    start_time = time()
    contador_str = str(x)
    img = cv2.imread(ruta + contador_str + extension)
    img_resized = cv2.resize(img, (500, 500), 0, 0, cv2.INTER_CUBIC)
    while (elapsed_time <= 3):
        elapsed_time = time() - start_time
        cv2.imshow('Progress', img_resized)

cv2.waitKey(0)
cv2.destroyAllWindows()

PS: I used OpenCV because it is what I use when I do image processing and I do not know any other way to show them, but it is not strictly necessary.

Health and thanks!

    
asked by NEA 14.10.2018 в 10:07
source

0 answers