title: I get TypeError: only integer scalar arrays can be converted to a scalar index when I send frames of video to function meant for pictures
body: <p>I'm working on simple human detection and Im running to problem when I try to use working code for image on video.</p>
  <pre><code>import cv2
  import numpy as np
  import matplotlib.pyplot as plt
  import pandas as pd
  
  classy = None
  with open('config/coco.names', 'r') as f:
    classes = [line.strip() for line in f.readlines()]
    
  net = cv2.dnn.readNet('config/yolov3.weights', 'config/yolov3.cfg')
  def funkcia1(image_of_frame):
    i_width = image_of_frame.shape[1]
    i_height = image_of_frame.shape[0]
  
    net.setInput(cv2.dnn.blobFromImage(image_of_frame, 0.00392, (416,416), (0,0,0), True, crop=False))
    layer_names = net.getLayerNames()
    output_layers = [layer_names[i - 1] for i in net.getUnconnectedOutLayers()]
    outs = net.forward(output_layers)
  
    class_ids = []
    confidences = []
    boxes = []
  
    #create bounding box
    for out in outs:
      for dec in out:
        score = dec[5:]
        class_id = np.argmax(score)
        confidence = score[class_id]
        if confidence &gt; 0.1:
          center_x = int(dec[0] * i_width)
          center_y = int(dec[1] * i_height)
          w = int(dec[2] * i_width)
          h = int(dec[3] * i_height)
          x = center_x - w / 2
          y = center_y - h / 2
          class_ids.append(class_id)
          confidences.append(float(confidence))
          boxes.append([x, y, w, h])
  
    indices = cv2.dnn.NMSBoxes(boxes, confidence, 0.1, 0.1)
    #check if people 
    for i in indices:
      #i = i[0]
      box = boxes[i]
      if class_ids[i]==0:
        label = str(classes[class_id])
        cv2.rectangle(image_of_frame, (round(box[0]),round(box[1])), (round(box[0]+box[2]),round(box[1]+box[3])), (255, 0, 0), 2)
        cv2.putText(image_of_frame, label, (round(box[0])-10,round(box[1])-10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 0, 0), 2)
    image_of_frame = cv2.cvtColor(image_of_frame, cv2.COLOR_BGR2RGB)
    return image_of_frame
  </code></pre>
  <p>This code for detecting humans on picture is working ok but when I try to read video and send to function frame by frame Im getting this error</p>
  <pre><code>---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-59-fef194f508e7&gt; in &lt;module&gt;()
       12     out.release()
       13     break
  ---&gt; 14   output = funkcia1(frame)
       15   if counter % 2 == 0:
       16     out.write(output)
  
  1 frames
  &lt;ipython-input-57-d1c079f6911b&gt; in &lt;listcomp&gt;(.0)
       15   net.setInput(cv2.dnn.blobFromImage(image_of_frame, 0.00392, (416,416), (0,0,0), True, crop=False))
       16   layer_names = net.getLayerNames()
  ---&gt; 17   output_layers = [layer_names[i - 1] for i in net.getUnconnectedOutLayers()]
       18   outs = net.forward(output_layers)
       19 
  
  TypeError: only integer scalar arrays can be converted to a scalar index
  </code></pre>
  <p>This is code for loading video and sending frame by frame to function:</p>
  <pre><code>import cv2
  
  cap = cv2.VideoCapture('input/school_test.mp4')
  ret, frame = cap.read()
  frame_height, frame_width, _ = frame.shape
  out = cv2.VideoWriter('output/school_test_o_counter.mp4', cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'), 10, (frame_width, frame_height))
  print(&quot;Processing video ...&quot;)
  counter = 0
  while cap.isOpened():
    ret, frame = cap.read()
    if not ret:
      out.release()
      break
    output = funkcia1(frame)
    if counter % 2 == 0:
      out.write(output)
    counter = counter + 1
  out.release()
  print(&quot;Done porecessing video&quot;)
  </code></pre>
  <p>I tried to look on stack for this error but couldnt work it out so can you explain to me why I am getting error when I send frame and not when I send .jpg from file?</p>