diff --git a/aid03/do_MR60_graph.py b/aid03/do_MR60_graph.py new file mode 100644 index 0000000..0af70fb --- /dev/null +++ b/aid03/do_MR60_graph.py @@ -0,0 +1,42 @@ +import cv2 +import numpy as np +from time import sleep +from os import path +from subprocess import Popen, PIPE +iHeight, iWidth = 720, 1280 +image = np.zeros((iHeight, iWidth, 3), np.uint8) + +#home_dir = "/home/user/SmartBed/src" +home_dir = path.dirname(path.abspath(__file__)) + + +def make_MR_graph(image, devid, dlt): # микрорадар 60GHz + datadir = "log" + lcnt = 1 + log = "%s/%s/pox_dat.R60_8266_%s" % (home_dir, datadir, devid) + if not path.isfile(log): + return(image) + databuf = Popen(["tail", "-n%i" % lcnt, log], stdout=PIPE, encoding='utf-8').communicate()[0] + line = databuf.split("\t") + tdat = line[1].split(", ") + ttime = line[0].split(".")[0] + imH, imW, colors = np.shape(image) # [1080, 1920] + c0 = (255, 0, 0) + c1 = (0, 255, 0) + c2 = (0, 0, 255) + c3 = (0, 255, 255) + cv2.putText(image, "%s:heart[%s], breath[%s], dist[%s], move[%s] [%s]" % (devid, tdat[1], tdat[3], tdat[5], tdat[7], ttime), (20, int(imH/2-50+dlt)), cv2.FONT_HERSHEY_SIMPLEX, 1, c2, 2) + return(image) + +while True: + image = image * 0 + image = make_MR_graph(image, "01", 0) + image = make_MR_graph(image, "02", 40) + cv2.imshow('SmartBed', image) + if cv2.waitKey(1) == 27: + break + cv2.imwrite('img.png', image) + sleep(1) +#cam.release() +cv2.destroyAllWindows() +