I want to read input from camera and append frame in a list, display the frame from list. The code takes much time to read a frame and display it, after appending into the list.
JavaScript
x
18
18
1
def test(source_file):
2
ImagesSequence=[]
3
i=0
4
capture = VideoCapture(source_file)
5
while(1):
6
ret, frame = capture.read()
7
while(True):
8
imshow('Input', frame)
9
10
ImagesSequence.append(frame)
11
imshow('Output',ImagesSequence[i].astype(np.uint8))
12
i=i+1
13
if cv2.waitKey(60) & 0xFF == ord('q'):
14
break
15
return ImagesSequence
16
17
test(0)
18
Advertisement
Answer
As Christoph pointed out, you have an actual infinite loop running in the program, removing it will fix your program.
JavaScript
1
18
18
1
def test(source_file):
2
ImagesSequence=[]
3
i=0
4
capture = cv2.VideoCapture(source_file)
5
6
while True:
7
ret, frame = capture.read()
8
cv2.imshow('Input', frame)
9
ImagesSequence.append(frame)
10
cv2.imshow('Output',ImagesSequence[i].astype(np.uint8))
11
12
i=i+1
13
if cv2.waitKey(1) & 0xFF == ord('q'):
14
break
15
return ImagesSequence
16
17
test(0)
18