title: Display live camera feed with object recognition markers Python ImageAI OpenCV
body: <p>I've been using the image AI library to create a simple object detection system using python, which currently records video using the webcam and as far as I can tell detects objects live, once the program stops, a video file is created with object markers overlayed on the video. The working code:</p>
  <pre><code>from imageai.Detection import VideoObjectDetection
  import os
  import cv2
  
  camera = cv2.VideoCapture(0)
  
  current_directory = os.getcwd()
  
  detector = VideoObjectDetection()
  
  detector.setModelTypeAsYOLOv3()
  
  detector.setModelPath(r&quot;C:\Users\Luca\Desktop\image\yolo.h5&quot;)
  detector.loadModel()
  
  detections = detector.detectObjectsFromVideo(
  camera_input=camera,
  output_file_path = r&quot;C:\Users\Luca\Desktop\image\footage_detected&quot;, frames_per_second=20, log_progress=True)
  
  for eachObject in detections:
      print(
           eachObject[&quot;name&quot;] , &quot; : &quot;,
           eachObject[&quot;percentage_probability&quot;], &quot; : &quot;,
           eachObject[&quot;box_points&quot;] )
      print(&quot;--------------------------------&quot;)
  vid.release()
  cv2.destroyAllWindows()
  </code></pre>
  <p>I would like the program to display each frame on the display as it is being recorded <em>with</em> the object markers overlayed on the live feed as it detects them. I am only able to get the live camera feed directly from opencv without the object markers.</p>
  <p>I attempted to use opencv and imageai to take each frame, use the <code>detectObjectsFromImage</code> method to process each frame and then using the output of the method with the opencv <code>imshow</code> method. However it gives the error:</p>
  <blockquote>
  <p>ValueError: &quot;Ensure you specified correct input image, input type,
  output type and/or output image path&quot;</p>
  </blockquote>
  <p>Here is the code where I attempt to do this:</p>
  <pre><code>from imageai.Detection import ObjectDetection
  import os
  import cv2
  
  current_directory = os.getcwd()
  
  camera = cv2.VideoCapture(0)
  
  
  detector = ObjectDetection()
  
  detector.setModelTypeAsYOLOv3()
  
  detector.setModelPath(r&quot;C:\Users\Luca\Desktop\image\yolo.h5&quot;)
  detector.loadModel()
  while True:
      ret, frame = camera.read()
  
      returned_image, detections = detector.detectObjectsFromImage(
      input_image = (frame),
      output_type = &quot;array&quot;
      )
      for eachObject in detections:
          print(
               eachObject[&quot;name&quot;] , &quot; : &quot;,
               eachObject[&quot;percentage_probability&quot;], &quot; : &quot;,
               eachObject[&quot;box_points&quot;] )
          print(&quot;--------------------------------&quot;)
  
      cv2.imshow('frame', returned_image)
      if cv2.waitKey(1) &amp; 0xFF == ord('q'):
          break
  </code></pre>
  <p>Please let if this is possible, and if so how can it be done using the ImageAI library?
  Thank you in advance.</p>
  <p>Edit: here is the complete traceback.</p>
  <pre class="lang-txt prettyprint-override"><code>Traceback (most recent call last):
    File &quot;C:\Users\Luca\anaconda3\envs\objectreconition\lib\site-packages\imageai\Detection\__init__.py&quot;, line 285, in detectObjectsFromImage
      input_image = cv2.imread(input_image)
  TypeError: Can't convert object to 'str' for 'filename'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;C:\Users\Luca\Desktop\image\main 2.py&quot;, line 22, in &lt;module&gt;
      output_type = &quot;array&quot;
    File &quot;C:\Users\Luca\anaconda3\envs\objectreconition\lib\site-packages\imageai\Detection\__init__.py&quot;, line 392, in detectObjectsFromImage
      &quot;Ensure you specified correct input image, input type, output type and/or output image path &quot;)
  ValueError: Ensure you specified correct input image, input type, output type and/or output image path
  </code></pre>