title: How to use readNet (or readFromDarknet) instead of readNetFromCaffe?
body: <p>I did an object detection using opencv by loading pre-trained  MobileNet SSD model. <a href="https://www.pyimagesearch.com/2018/08/13/opencv-people-counter/" rel="nofollow noreferrer">from this post</a>.
  It reads a video and detects objects without any problem. But I would like to use <code>readNet</code> (or <code>readFromDarknet</code>) instead of <code>readNetFromCaffe</code> </p>
  
  <p><code>net = cv2.dnn.readNetFromCaffe(args["prototxt"], args["model"])</code></p>
  
  <p>because I have pre-trained weights and cfg file of <strong>my own objects</strong> only in Darknet framework. Therefore I simply changed <code>readNetFromCaffe</code> into <code>readNet</code> in <strong>above post</strong> and got an error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "people_counter.py", line 124, in &lt;module&gt;
      for i in np.arange(0, detections.shape[2]):
  IndexError: tuple index out of range
  </code></pre>
  
  <p>Here <code>detections</code> is an output from </p>
  
  <pre><code>blob = cv2.dnn.blobFromImage(frame, 1.0/255.0, (416, 416), True, crop=False)
  net.setInput(blob)
  detections = net.forward()
  </code></pre>
  
  <p>Its shape is (1, 1, 100, 7) <strong>tuple</strong> (when using <code>readNetFromCaffe</code>).</p>
  
  <p>I was kinda expecting it wouldn't work just by changing the model. Then I decided to look for an object detector code where <code>readNet</code> was used and  I found it <a href="https://github.com/arunponnusamy/object-detection-opencv/blob/master/yolo_opencv.py" rel="nofollow noreferrer">here</a>. I read through the code and found the same lines as follows:</p>
  
  <pre><code>blob = cv2.dnn.blobFromImage(image, scale, (416,416), (0,0,0), True, crop=False)
  net.setInput(blob)
  outs = net.forward(get_output_layers(net))
  </code></pre>
  
  <p>Here, the shape of <code>outs</code> is (1, 845, 6) <strong>list</strong>. But in order for me to be able to use it right away (<a href="https://www.pyimagesearch.com/2018/08/13/opencv-people-counter/" rel="nofollow noreferrer">here</a>),   <code>outs</code> should be of the same size with <code>detections</code>. I've come up to this part and have no clue about how I should proceed.</p>
  
  <p>If something isn't clear, I just need help to use <code>readNet</code> (or <code>readFromDarknet</code>) instead of <code>readNetFromCaffe</code> in <a href="https://www.pyimagesearch.com/2018/08/13/opencv-people-counter/" rel="nofollow noreferrer">this post</a>  </p>