基于人工智能的摄像机监控报警系统

CamAi-castleguarders的Python项目详细描述


在===== 卡迈

CamAi采用人工智能优先的方法来监控和描述视频流。传统的开源软件包,如ZoneMinder和其他软件,主要依靠运动检测和手工制作的“区域”来减少错误检测。现代摄像机支持更高的分辨率(FHD、4MP、5MP、4K等),这就要求对视频流进行始终如一的低延迟处理,而旧的系统似乎在处理这些问题。在

CamAi试图利用“多cpu核”的优势,并采用了大量线程,以确保对“多”源进行可靠的高分辨率视频流处理。它还使用更现代的方法,如实例分割、人脸检测和人脸识别来降低误警率。虽然这需要一个GPU/s来获得合理的性能,但是与传统cpu核心捆绑在一起的推理引擎是未来的发展方向。它需要一种数据科学的方法,使人们能够随着时间的推移学习可能是正常的或其他的,并在采取行动时更接近人类。这些特性中的一些在“云”摄像机中是可用的,比如Ring:sup:tm;,Nest:sup:tm;,它需要将视频流发送到“他们的”云中,并且附带许多非自愿的“共享”功能。CamAi可以在网络内完成这一切,无论是否有摄像头流的外部连接。在

当然可以尝试将这些特性“移植”到现有系统中。然而,这会导致语言和技术的混乱(仅限perl/c++/windows)或部分开源。CamAI的目标是拥有一个更加现代、可维护和可扩展的代码库,它完全是开源的、跨平台的(随着时间的推移)和现代化的,而不必放弃对“云”摄像机的控制和可见性。在

在============ 安装

要求

开发主要基于ubuntu18.04。在

在Ubuntu中安装Ubuntu包_德普.txt. bash./乌班图-德普.txt在

安装用于tensorflow加速的Nvidia CUDA 使用Cuda 10.0(非10.1)、CuDNN 7.5和Tensorflow 1.13/1.14进行测试 在这些版本之后的任何兼容组合都应该可以工作。在

It's possible to run tensorflow without CUDA, but it will most likely be impractically slow. If you use CamAi in record only mode, a GPU will not be essential.

在中安装Pip3包要求.txt 可选但建议:为camai创建一个虚拟环境 mkdir卡迈 #如果您还没有virtualenv,或者想使用更新的版本 pip3 install virtualenv--用户 virtualenv-pPython3.7 venv37

^{pr2}$

快跑 在网络上发现与onvif兼容的摄像头并生成配置文件

./CamAi/camaicli.py discover
or if installed from a wheel
python3.7 ~/venv37/lib/python3.7/site-packages/CamAi/camaicli.py discover 

Start monitoring with 
./CamAi/camaicli.py monitor 
or if installed from a wheel
python3.7 ~/venv37/lib/python3.7/site-packages/CamAi/camaicli.py monitor

If you want to specify a configuration file in a different location you can add --config config.toml to the above
python3.7 ~/venv37/lib/python3.7/site-packages/CamAi/camaicli.py monitor

This should start logging videos to storage directories you specified in the config file.
You cannot open the video being currently logged till it's rotated. Default rotation is 30 minutes at hourly boundaries, so you should be able to open it after next hours starts. Alert images and snippet videos are generated in realtime and are located at the base directory for viewing.

在============== 配置

下面是一个示例配置文件凸轮轴.py--发现选项生成。配置文件可以手工制作。主要有三个部分。在

相机 必须有一个或多个摄像头部分。此部分包含特定于摄像头的配置和策略信息。相机部分由一个主部分和一个子部分组成。子部分用于指定此相机的一个或多个感兴趣的对象以及特定于对象的设置。在

Email部分 它包含一个电子邮件发件人和零个或多个电子邮件收件人部分

Manager部分 此部分具有CamAi运行时默认值。如果用户未指定每个摄影机的目录,则将使用manager sections basedir变量作为每个摄影机的父级。::

  [[camera]]
  hostname = "192.168.2.10"   <--- Largely ceremonial (Not mandatory)
  port = 8000                 <--- Onvif port  (Not mandatory)
  username = "admin"          <--- Not used yet, earlier versions used this to construct the URL
  password = "blahblah"       <--- Not used yet, earlier versions used this to construct the URL
  name = "Garage Walkway"     <--- Make this human consumable as it shows up in alerts/logs etc (Required)
  url = "rtsp://admin:blahblah@192.168.1.10:554/h264Preview_01_main" (Required)
  fps = 22                    <--- Gets used, use a sane number (Recommended)
  snapshoturl = "http://192.168.1.10:80/onvifsnapshot/snapshot_channel01.jpg" <--- (Not used yet)
  readbuffer = 78643200       <--- 16 x resolution is generally recommended (Required)
  resolution = "2560x1920"    <--- Not mandatory
  enableptz = false           <--- Not used yet
  subdir = "./videos/Garage Walkway"  <--- Recommended, manager sections basedir + name is used otherwise
  mode = "detect_and_record_timelapse" <--- Required
  rotation = 0                <--- Required if image is not oriented correctly
  watchdogenable = true       <--- Only set to false if camera is actually just a video file 
  watchdogtimer = 60          <--- Default is good
  annotation = false          <--- Leave to false other than when image masking figuring out false detects, intensive overhead
  showlivevideo = false       <--- Not used yet, older versions us
  facedetection = false       <--- Hmm, this needs to deprecated as 'instancedetection' under objects of interest is the right
  maxreadqueue = 32           <--- Tweak per your memory availability, memory consumed is this times resolution
  detectionrate = 25          <--- Detection frequency, these many frames are skipped between detections
  detecttrackseconds = 30     <--- Automatically track this many seconds if object of interest is detected
  deletepolicyenabled = true  <--- Enable automatic storage management
  deletethreshold = 60        <--- Start deleting when overall disk usage reaches this percentage
  deleteeventsthreshold = 80  <--- Start deleting videos with events when overall disk usage reaches this percentage
  deleteafterdays = 7         <--- Only delete after this many days
  log_object_timeseries = true <--- Leave at true, used for instance detection and reducing redundant notifications

  [camera.objects_of_interest.person] <--- Sub section for an object of interest, in this case a 'person' object
  detection_threshold = 0.98          <--- How confident the model should be that this object was detected
  instance_match_threshold = 75       <--- How confident the model should be that this is the known person based on face recognition
  instance_watch_timerange_start = 8  <--- Suppress alerts if the same object is seen within the last 8 minutes
  instance_watch_timerange_end = 2    <--- Works with above, when to start looking if the object was last seen, default is 2 mins ago
  instance_watch_continuous_mode = false  <--- The object has to be continually present within the watch timerange otherwise 
                                               alerts will be triggered 
  instancedetection = false           <--- Face recognition if it's a person object, (licenses for vehicles will also use this)
  notify_startup_wait = 5             <--- How long to wait after startup before notifying, otherwise it will report existing objects

  [camera.objects_of_interest.car]
  detection_threshold = 0.85
  instance_match_threshold = 65
  instance_watch_timerange_start = 6
  instance_watch_timerange_end = 2
  instance_watch_continuous_mode = false
  instancedetection = false
  notify_startup_wait = 5

  [camera.objects_of_interest.motorcycle]
  detection_threshold = 0.98
  instance_match_threshold = 75
  instance_watch_timerange_start = 8
  instance_watch_timerange_end = 2
  instance_watch_continuous_mode = false
  instancedetection = false
  notify_startup_wait = 5

  [camera.objects_of_interest.truck]
  detection_threshold = 0.85
  instance_match_threshold = 65
  instance_watch_timerange_start = 6
  instance_watch_timerange_end = 2
  instance_watch_continuous_mode = false
  instancedetection = false
  notify_startup_wait = 5

  [camera.objects_of_interest.bus]
  detection_threshold = 0.98
  instance_match_threshold = 75
  instance_watch_timerange_start = 8
  instance_watch_timerange_end = 2
  instance_watch_continuous_mode = false
  instancedetection = false
  notify_startup_wait = 5

  [camera.objects_of_interest.bicycle]
  detection_threshold = 0.98
  instance_match_threshold = 75
  instance_watch_timerange_start = 8
  instance_watch_timerange_end = 2
  instance_watch_continuous_mode = false
  instancedetection = false
  notify_startup_wait = 5

  [["email recepient"]]  <--- Can have any number of recipients
  name = "First Last"   <--- Recipient Name
  email_address = "myemail@example.com"   <--- Recipient Email

  ["email sender"]
  sender_email = "firstlast@example.com"   <--- Email address from which the alerts are sent
  sender_login = "firstlast@example.com"   <--- Login to use to authenticate with the smtp server
  smtp_server = "mail.example.com"         <--- Your email providers SMTP
  smtp_server_port = 465                   <--- SSL SMTP Server Port
  login_required = true                    <--- Only authenticated SMTP is supported 
  use_SSL = true                           <--- Only SSL SMTP is supported 
  sender_secret = "blahblahpassword"       <--- The password

  ["manager options"]
  basedir = "./videos/"                    <--- Default storage location if not overriden on a per camera basis
  numdetectors = 1                         <--- Number of detector processes, if more than 1, multiprocessing_detector 
                                                and multiprocessing_observer has to be true
  pipelineresize = true                    <--- Image resizing for detection, doing it per camera (vs in detector) reduces latency 
  singledetectorqueue = true               <--- Use a single queue for all cameras vs one queue for all cameras, single is cheaper
  defaultmaxqueue = 32                     <--- Default queue size, per camera override exists
  multiprocessing_observer = false         <--- Leave these settings as is for now
  multiprocessing_detector = false
  multiprocessing_reader = false
  multiprocessing_writer = false
  multiprocessing_notifier = true
  multiprocessing_viewer = false
  multiprocessing_trainer = true

选择相机操作模式 CamAi支持四种工作模式。该模式可根据每个摄像头进行配置。生成的默认模式

    *detect_and_record_timelapse* 
            Detection is on for the camera, and frames are recorded in a timelapse fashion at sample interval specified by 'detectionrate'. If any objects of interest are observed, the recording becomes continuous the number of seconds specified by 'detecttrackseconds' for that camera. If facedetection/instancedetection is enabled, the frames are further processed to scan for known instances before generating alerts. 

    *detect_and_record_everything*
            This mode works similar to detect_and_record_timelapse, except that all frames are recorded whether or not an object of interest is detected or otherwise.

    *detect_only*
            This mode works similar to detect_and_record_timelapse, except that no video is recorded (other than short alert clips). Alerting etc. works exactly the same.

    *record_only*
            This mode turns off any detection and records every frame.

设置人脸识别 创建已知面目录。遵循示例目录层次结构。 现在把这个放在camai目录下。标准图片 像jpg/gif/png/bmp这样的格式应该可以工作。每一张图片应该只有 名为父目录的人的脸。::

^{公共关系六}$

警报 支持以下类型的警报。在

    *Verbal*
            When a new object of interest is detected, it is announced locally on the computer thats running camai. 

。。图像::文档/警报_存储.png :宽度:50 :高度:150 :alt:口头警告

    *Email*
            When a new object of interest is detected, emails alerts are sent to the recipients specified in the configuration file. Each object of interest results in two emails, the first one with a single image and a follow up one with a short video clip. This is so that email size limits do not cause alerts to be missed.

。。图像::文档/电子邮件警报_图像.png :宽度:50 :高度:150 :alt:通过电子邮件发送带有图像的警报

。。图像::文档/电子邮件警报_视频.png :宽度:50 :高度:150 :alt:通过电子邮件发送带有视频的警报

    *Stored*
            Every alerts image and video clipping is stored by default in the 'basedir' specified in the manager section. These alert files are not automatically pruned or managed unlike the video recordings.

。。图像::文档/警报_存储.png :宽度:50 :高度:150 :alt:存储警报图像

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何从IBM MQ的JMSException检测可恢复错误   java Lucene6。4.2:找不到类,尝试添加查询。   Java Pdf差异库   在Java中多线程处理我的线程   java将字符串传递给Uri。下载中的parse()   java在列表中查找原语位置   java JPA条件从另一个查询中选择   java中的强制转换和转换   java如何在没有上下文的情况下获取SOAP Web服务(Apache Axis 1.4)的调用客户端的IP地址   java Android IllegalBlockSizeException:解密中最后一个块未完成   java Jersey是否要自定义无效资源路径的错误处理?   如何将JavaCVS web项目转换为基于maven的web项目?   java如何检查通用列表是否与jUnit相等?   arraylist java。util。尝试使用迭代器时发生ConcurrentModificationException错误   使用springsecurity,jsp上的java${u csrf.token}始终为空   sql使用java从临时表中选择数据   spring验证中的java@Notnull和@Pattern无效   java如何使用jQuery将包含对象数组的对象数组传递给Spring MVC控制器?