Ready for Tomorrow

This commit is contained in:
2021-11-08 16:01:55 -06:00
parent fd02667267
commit 0331882a49

17
main.py
View File

@@ -1,6 +1,8 @@
import cv2 import cv2
import numpy as np import numpy as np
cap = cv2.VideoCapture("rtsp://192.168.1.81/vaddio-conferenceshot-eptz-stream") cap = cv2.VideoCapture(1)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
max_count = 0 max_count = 0
# Text # Text
@@ -10,11 +12,12 @@ org2 = (50, 90)
fontScale = 1 fontScale = 1
color = (255, 0, 0) color = (255, 0, 0)
thickness = 2 thickness = 2
scale = 6
while True: while True:
ret, src = cap.read() ret, src = cap.read()
upper_left = (int(src.shape[1]/4),int(src.shape[0]/4)) center = (int(src.shape[0]/2),int(src.shape[1]/2))
lower_right = (int(src.shape[1]/4 + src.shape[1]/2),int(src.shape[0]/4 + src.shape[0]/2) ) upper_left = (int(center[1] - src.shape[1]/scale),int(center[0] - src.shape[0]/scale))
lower_right = (int(center[1] + src.shape[1]/scale),int(center[0] + src.shape[0]/scale))
gray = cv2.cvtColor(src[upper_left[1]:lower_right[1],upper_left[0]:lower_right[0]], cv2.COLOR_BGR2GRAY) 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) sobel = cv2.Sobel(gray, cv2.CV_8U, 1, 0, ksize=3)
@@ -23,9 +26,9 @@ while True:
if count > max_count: if count > max_count:
max_count = count max_count = count
src = cv2.putText(src, 'Max: {}'.format(max_count), org, font, fontScale, src = cv2.putText(src, 'Max: {}'.format(int(max_count/10000)), org, font, fontScale,
color, thickness, cv2.LINE_AA) color, thickness, cv2.LINE_AA)
src = cv2.putText(src, 'Current: {}'.format(count), org2, font, fontScale, src = cv2.putText(src, 'Current: {:.2f}%'.format((count/max_count)*100 - 0.01), org2, font, fontScale,
color, thickness, cv2.LINE_AA) color, thickness, cv2.LINE_AA)
src = cv2.rectangle(src, pt1=upper_left, pt2=lower_right, color=(36,255,12), thickness=1) src = cv2.rectangle(src, pt1=upper_left, pt2=lower_right, color=(36,255,12), thickness=1)
cv2.imshow('tresh', thresh) cv2.imshow('tresh', thresh)
@@ -35,3 +38,5 @@ while True:
k = cv2.waitKey(10) k = cv2.waitKey(10)
if k == 27: if k == 27:
break break
elif k == 32:
max_count = 0