fix: snap_and_analyse时更新缓存
This commit is contained in:
parent
284a36e24c
commit
64bdd72146
|
@ -603,16 +603,23 @@ def get_area_from_point(x: int, y: int, floorNo: str, area_fix_id):
|
||||||
def snap_and_analyse(vchannel: TDevice, algo_codes: list, opl: Opl = None):
|
def snap_and_analyse(vchannel: TDevice, algo_codes: list, opl: Opl = None):
|
||||||
global_img_o = dhClient.snap(vchannel.code, raise_exception=False)
|
global_img_o = dhClient.snap(vchannel.code, raise_exception=False)
|
||||||
happen_time = timezone.now()
|
happen_time = timezone.now()
|
||||||
if global_img_o is None: # 说明视频抓拍失败
|
|
||||||
ckey = 'vchannel_' + vchannel.id
|
ckey = 'vchannel_' + vchannel.id
|
||||||
cvalue = cache.get(ckey, None)
|
cvalue = cache.get(ckey, {})
|
||||||
|
if global_img_o is None: # 说明视频抓拍失败
|
||||||
if cvalue:
|
if cvalue:
|
||||||
try:
|
try:
|
||||||
cvalue.update({'snap': 'fail', 'snap_time': datetime.strftime("%Y-%m-%d %H:%M:%S")})
|
cvalue.update({'snap': 'fail', 'snap_time': datetime.now().strftime("%Y-%m-%d %H:%M:%S")})
|
||||||
cache.set(ckey, cvalue)
|
cache.set(ckey, cvalue, timeout=60)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
if cvalue:
|
||||||
|
try:
|
||||||
|
cvalue.update({'snap': 'success', 'snap_time': datetime.now().strftime("%Y-%m-%d %H:%M:%S")})
|
||||||
|
cache.set(ckey, cvalue, timeout=60)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
ec_codes = ai_analyse_2(algo_codes, global_img=global_img_o) # 算法处理返回的事件结果
|
ec_codes = ai_analyse_2(algo_codes, global_img=global_img_o) # 算法处理返回的事件结果
|
||||||
if ec_codes:
|
if ec_codes:
|
||||||
# 获取本次所有发生事件种类
|
# 获取本次所有发生事件种类
|
||||||
|
|
|
@ -137,7 +137,7 @@ def monitor_check(vc_ids = []):
|
||||||
ckey = 'vchannel_' + vc.id
|
ckey = 'vchannel_' + vc.id
|
||||||
if algo_codes:
|
if algo_codes:
|
||||||
tid = str(uuid.uuid4())
|
tid = str(uuid.uuid4())
|
||||||
cache.set(ckey, {'id': tid, 'algo_codes': algo_codes, 'start_time': datetime.strftime("%Y-%m-%d %H:%M:%S")})
|
cache.set(ckey, {'id': tid, 'algo_codes': algo_codes, 'start_time': datetime.now().strftime("%Y-%m-%d %H:%M:%S")}, timeout=60)
|
||||||
Thread(target=loop_and_analyse, args=(vc, tid), daemon=True).start()
|
Thread(target=loop_and_analyse, args=(vc, tid), daemon=True).start()
|
||||||
else:
|
else:
|
||||||
cache.delete(ckey)
|
cache.delete(ckey)
|
||||||
|
|
Loading…
Reference in New Issue