From 1f1118ec310fd3049d33956d640c089775e532b4 Mon Sep 17 00:00:00 2001 From: RobViren Date: Mon, 8 Nov 2021 13:32:34 -0600 Subject: [PATCH] Init --- .vscode/settings.json | 3 +++ main.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 main.py diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..b26f7c4 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.pythonPath": "/bin/python" +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..d55e04c --- /dev/null +++ b/main.py @@ -0,0 +1,37 @@ +import cv2 +import numpy as np +cap = cv2.VideoCapture("rtsp://192.168.1.81/vaddio-conferenceshot-eptz-stream") +max_count = 0 + +# Text +font = cv2.FONT_HERSHEY_SIMPLEX +org = (50, 50) +org2 = (50, 90) +fontScale = 1 +color = (255, 0, 0) +thickness = 2 + +while True: + ret, src = cap.read() + upper_left = (int(src.shape[1]/4),int(src.shape[0]/4)) + lower_right = (int(src.shape[1]/4 + src.shape[1]/2),int(src.shape[0]/4 + src.shape[0]/2) ) + + gray = cv2.cvtColor(src[upper_left[1]:lower_right[1],upper_left[0]:lower_right[0]], cv2.COLOR_BGR2GRAY) + sobel = cv2.Sobel(gray, cv2.CV_8U, 1, 0, ksize=3) + t, thresh = cv2.threshold(sobel, 200, 255, cv2.THRESH_BINARY) + count = np.sum(sobel) + if count > max_count: + max_count = count + + src = cv2.putText(src, 'Max: {}'.format(max_count), org, font, fontScale, + color, thickness, cv2.LINE_AA) + src = cv2.putText(src, 'Current: {}'.format(count), org2, font, fontScale, + color, thickness, cv2.LINE_AA) + src = cv2.rectangle(src, pt1=upper_left, pt2=lower_right, color=(36,255,12), thickness=1) + cv2.imshow('tresh', thresh) + cv2.imshow('src', src) + cv2.imshow('sobel', sobel) + + k = cv2.waitKey(10) + if k == 27: + break