Beispiel #1
0
    def add_cam_in_conf(cam_ip, cam_auth_login, cam_auth_password):

        is_connectable = CameraStream.is_connectable_cam_params(
            cam_ip=cam_ip,
            auth_login=cam_auth_login,
            auth_password=cam_auth_password)

        if is_connectable:
            MDBQuery.insert_camera(cam_ip)
            MConfig.add_camera(cam_ip, cam_auth_login, cam_auth_password)

        else:
            log('Camera is not connectable')
Beispiel #2
0
    def connect2db():
        conf_db = MConfig.get_by_name('DATABASE')
        try:
            MDBQuery.connect2db(dbname=conf_db['database'],
                                user=conf_db['user'],
                                password=conf_db['password'],
                                host=conf_db['host'])
        except Exception as e:
            print(e)
            log_error('Failde to connect to database')
            return

        log_info('Successfy connection to dabadase')

        n_db_version = MDBQuery.check_version(float(conf_db['version']))
        if n_db_version != float(conf_db['version']):
            MConfig.set_db_version(n_db_version)
Beispiel #3
0
    def _start_cam(cam_conf, interval, save_dir, debug=False):
        if not 'cam_fps' in cam_conf:
            cam_fps = CameraStream.check_cam_fps(**cam_conf)
            cam_conf = MConfig.edit_camera_by_ip(cam_conf['cam_ip'], {
                'cam_fps': cam_fps,
            })
        handler = lambda frame, cam_ip, send_time: \
            MDispatcher._new_thread_of_handler_of_taked_frames(
                frame, cam_ip, save_dir, send_time
            )
        cam = CameraStream(**cam_conf,
                           debug=debug,
                           handler_of_taked_frames=handler)

        cam.open(save_interval=interval)
        MDispatcher.cameras_streams[cam_conf['cam_ip']] = cam
Beispiel #4
0
 def db_init(db_user, db_password, db_name):
     MConfig.init_config_db(user=db_user,
                            password=db_password,
                            db_name=db_name)
Beispiel #5
0
 def _get_camera_from_conf(choice):
     if type(choice) is int or choice.isdigit():
         return MConfig.get_camera_by_id(int(choice))
     else:
         return MConfig.get_camera_by_ip(choice)
Beispiel #6
0
 def get_database_conf():
     return MConfig.get_by_name('DATABASE')
Beispiel #7
0
 def get_cameras_list():
     res = []
     for i, cam_ip in enumerate(MConfig.get_cameras_ip_list()):
         res.append(
             [i, cam_ip, cam_ip in MDispatcher.cameras_streams.keys()])
     return res
Beispiel #8
0
 def del_cam_from_config(choice):
     if choice.isdigit():
         MConfig.del_camera_by_id(int(choice))
     else:
         MConfig.del_camera_by_ip(choice)
Beispiel #9
0
 def start_all_cam_with_interval(interval, save_dir):
     cameras_conf = MConfig.get_all_cameras()
     for cam_conf in cameras_conf:
         if not cam_conf['cam_ip'] in MDispatcher.cameras_streams.keys():
             MDispatcher._start_cam(cam_conf, interval, save_dir)