Exemple #1
0
def aged_status_sync(aged):
    '''
    读取数据库中该用户的数据记录赋值为初始值
    :param aged: PoseInfo对象实例
    :return: None
    '''
    # 拼接url,参考接口文档
    aged_today_status__url = Conf.Urls.PoseInfoUrl + "/" + str(aged.agesinfoid)
    print(f'get {aged_today_status__url}')

    try:
        aged_status_today = HttpHelper.get_items(aged_today_status__url)
    except Exception:  # 还没有数据记录
        return
    aged.timesit = aged_status_today.timeSit
    aged.timelie = aged_status_today.timeLie
    aged.timestand = aged_status_today.timeStand
    aged.timedown = aged_status_today.timeDown
    aged.timeother = aged_status_today.timeOther
    use_aged.status = PoseStatus.Lie.value
    # 报警条件判读
    if use_aged.status == PoseStatus.Down.value:
        use_aged.isalarm = True
    else:
        use_aged.isalarm = False


# 获取本机需要识别的摄像头视频地址信息
local_ip = '192.168.199.224'
local_ip = '192.168.1.60'
# 拼接url,参考接口文档
get_current_server_url = Conf.Urls.ServerInfoUrl + "/GetServerInfo?ip=" + local_ip
print(get_current_server_url)

current_server = HttpHelper.get_items(get_current_server_url)
print(current_server)

for camera in current_server.cameraInfos:  # 遍历本服务器需要处理的摄像头
    print(f'摄像头视频地址:{camera.videoAddress}')

    for aged in camera.roomInfo.agesInfos:  # 遍历本摄像头所在房间的老人信息
        print(f'被监控人:{aged.name}')

        ages[aged.id] = PoseInfo(agesInfoId=aged.id,
                                 date=time.strftime('%Y-%m-%dT00:00:00',
                                                    time.localtime()),
                                 timeStand=0,
                                 timeSit=0,
                                 timeLie=0,
                                 timeDown=0,