I am looking to complete a simple live feed object detection tutorial from the 'imageai' documentation (https://imageai.readthedocs.io/en/latest/video/index.html). As per tutorial the code is following:
from imageai.Detection import VideoObjectDetection
import os
import cv2
execution_path = os.getcwd()
camera = cv2.VideoCapture(0)
detector = VideoObjectDetection()
detector.setModelTypeAsYOLOv3()
detector.setModelPath(os.path.join(execution_path , "yolov3.pt"))
detector.loadModel()
video_path = detector.detectObjectsFromVideo(camera_input=camera,
output_file_path=os.path.join(execution_path, "camera_detected_video")
, frames_per_second=20, log_progress=True, minimum_percentage_probability=30)
print(video_path)
I have installed all the necessary packages for the tutorial (including opencv package in my environmental variable). However, once I run the code, I get the following error:
OpenCV: Couldn't read movie file "" [ERROR:0@1.705] global cap.cpp:166 open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.7.0) /private/var/folders/p5/T/pip-install-fu_8bn3g/opencv-python_/opencv/modules/videoio/src/cap_images.cpp:293: error: (-215:Assertion failed) !_filename.empty() in function 'open'
I saw that similar issue arose when the path for detectObjectFromImage was specified incorrectly. However, I do not understand how is it related here if I am using VideoCapture(0).
Thank you so much for the help!