videoAi.py 566 B

123456789101112131415161718192021
  1. '''Created Aug 18, 2021 deeejas'''
  2. from imageai.Detection import VideoObjectDetection
  3. import os
  4. import cv2
  5. execution_path = os.getcwd()
  6. camera = cv2.VideoCapture(0)
  7. detector = VideoObjectDetection()
  8. detector.setModelTypeAsYOLOv3()
  9. detector.setModelPath(os.path.join(execution_path, "yolo.h5"))
  10. detector.loadModel()
  11. video_path = detector.detectObjectsFromVideo(
  12. camera_input=camera,
  13. output_file_path=os.path.join(execution_path, "camera_detected_video"),
  14. frames_per_second=20, log_progress=True, minimum_percentage_probability=30)
  15. print(video_path)