解决ZeroDivisionError: float division by zero的问题

ZeroDivisionError: float division by zero的问题

在做多线程目标追踪项目中遇到这个问题

Traceback (most recent call last):
  File "E:/Python/multiobject-tracking-dlib/multi_object_tracking_fast.py", line 149, in <module>
    print("[INFO] approx. FPS: {:.2f}".format(fps.fps()))
  File "E:\Python\multiobject-tracking-dlib\utils.py", line 32, in fps
    return self._numFrames / self.elapsed()
ZeroDivisionError: float division by zero
warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:834)
warning:  (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:835)

解决:

p = argparse.ArgumentParser()
ap.add_argument("-p", "--prototxt", required=False, default= "E:/Python/multiobject-tracking-dlib/mobilenet_ssd/MobileNetSSD_deploy.prototxt",
	help="path to Caffe 'deploy' prototxt file")
ap.add_argument("-m", "--model", required=False, default= "E:/Python/multiobject-tracking-dlib/mobilenet_ssd/MobileNetSSD_deploy.caffemodel",
	help="path to Caffe pre-trained model")
ap.add_argument("-v", "--video", required=False, default= "E:/Python/multiobject-tracking-dlib/race.mp4",
	help="path to input video file")
ap.add_argument("-o", "--output", type=str,
	help="path to optional output video file")
ap.add_argument("-c", "--confidence", type=float, default=0.2,
	help="minimum probability to filter weak detections")

总结:

出现除数为0的情况,首先是检查数据类型是否出错,我遇到的问题是参数路径配置出现错误,修改之后正常运行。

你可能感兴趣的:(机器学习算法,计算机视觉,python,目标跟踪,计算机视觉)