title: How to print output of a function for every specified x frame from webcam
body: <p>I have a code which I want to open the webcam and then apply a function on each frame and then for every <code>x</code> frame I need to print the output that had maximum occurrence:</p>
  <p>For example I will open the webcam and I will apply a deepface function on each frame which returns emotion of the person in that frame. Now if <code>x</code> is equal to 10, it must print only one output for the first <code>x</code> frames which is the emotion that had maximum occurrence in <code>x</code> frames, then print only one emotion for the next 10 frames and so on.</p>
  <p>My code prints only empty strings. Can anybody tell what is wrong?</p>
  <pre><code>emotions_list = []
  
  while video.isOpened(): 
  
     _,frame = video.read()
  
     try:
  
          while(len(emotions_list)&lt; x):
              analyze = DeepFace.analyze(frame,actions=['emotion'])
              emotions_list.append(analyze['dominant_emotion'])  
          print(max(emotions_list,key=emotions_list.count))
          emotions_list.clear()
      except:
          print(&quot;&quot;)
      
      cv2.imshow('video', frame)
      key=cv2.waitKey(1) 
      if key==ord('q'):   # here we are specifying the key which will stop the loop and stop all the processes going
        video.release()
        break
  </code></pre>