Update
parent
af20c5f964
commit
7107c3a156
|
|
@ -15,12 +15,15 @@ class Camera:
|
|||
|
||||
def healthbeat(self):
|
||||
try:
|
||||
cap = cv2.VideoCapture(self.rtsp)
|
||||
ret, _ = cap.read()
|
||||
cap.release()
|
||||
|
||||
# 摄像头状态: 1 在线, 2 离线
|
||||
status = 1 if ret == True else 2
|
||||
status = 2
|
||||
|
||||
cap = cv2.VideoCapture(self.rtsp)
|
||||
if cap.isOpened():
|
||||
ret, _ = cap.read()
|
||||
cap.release()
|
||||
if ret == True:
|
||||
status = 1
|
||||
|
||||
if status == 1:
|
||||
logging.info("摄像头ID: %s, 状态: 在线" % (self.id))
|
||||
|
|
@ -32,7 +35,7 @@ class Camera:
|
|||
|
||||
with conn:
|
||||
with conn.cursor() as cursor:
|
||||
cursor.execute("update devices set status = %s, updated_at = %s where id = %s", (status, self.id, datetime.datetime.now()))
|
||||
cursor.execute("update devices set status = %s, updated_at = %s where id = %s", (status, datetime.datetime.now(), self.id))
|
||||
|
||||
conn.close()
|
||||
except Exception as e:
|
||||
|
|
|
|||
Loading…
Reference in New Issue