Init
This commit is contained in:
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"python.pythonPath": "/bin/python"
|
||||||
|
}
|
||||||
37
main.py
Normal file
37
main.py
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user