Fix video, rename image, add images to gitignore
This commit is contained in:
parent
57f8e55d2a
commit
a89e27abfc
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,4 @@
|
|||||||
*.pyc
|
*.pyc
|
||||||
camera/venv
|
camera/venv
|
||||||
|
camera/images
|
||||||
|
camera/videos
|
||||||
|
21
camera/.vscode/launch.json
vendored
Normal file
21
camera/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Python: Current File",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${file}",
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Python: Current File with args",
|
||||||
|
"type": "python",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${file}",
|
||||||
|
"console": "integratedTerminal",
|
||||||
|
"args": ["-v", "~/Videos/video.h264"]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
3
camera/.vscode/settings.json
vendored
Normal file
3
camera/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"python.pythonPath": "venv/bin/python"
|
||||||
|
}
|
Binary file not shown.
2
camera/person-detection.py → camera/image_presence.py
Normal file → Executable file
2
camera/person-detection.py → camera/image_presence.py
Normal file → Executable file
@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# import the necessary packages
|
# import the necessary packages
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from imutils.object_detection import non_max_suppression
|
from imutils.object_detection import non_max_suppression
|
33
camera/video_presence.py
Normal file → Executable file
33
camera/video_presence.py
Normal file → Executable file
@ -1,3 +1,5 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from imutils.video import VideoStream
|
from imutils.video import VideoStream
|
||||||
from imutils.video import FPS
|
from imutils.video import FPS
|
||||||
import argparse
|
import argparse
|
||||||
@ -87,8 +89,12 @@ while True:
|
|||||||
|
|
||||||
# dilate the thresholded image to fill in holes, then find contours on thresholded image
|
# dilate the thresholded image to fill in holes, then find contours on thresholded image
|
||||||
thresh = cv2.dilate(thresh, None, iterations=2)
|
thresh = cv2.dilate(thresh, None, iterations=2)
|
||||||
cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
|
thresh = np.uint8(thresh)
|
||||||
cnts = cnts[0] if imutils.is_cv2() else cnts[1]
|
cnts, im2 = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)
|
||||||
|
#cnts = cnts if imutils.is_cv2() else im2
|
||||||
|
#print(len(cnts))
|
||||||
|
#if len(cnts) > 1:
|
||||||
|
#cnts = cnts[0] if imutils.is_cv2() else cnts[1]
|
||||||
|
|
||||||
# loop over the contours identified
|
# loop over the contours identified
|
||||||
contourcount = 0
|
contourcount = 0
|
||||||
@ -103,8 +109,8 @@ while True:
|
|||||||
(x, y, w, h) = cv2.boundingRect(c)
|
(x, y, w, h) = cv2.boundingRect(c)
|
||||||
initBB2 =(x,y,w,h)
|
initBB2 =(x,y,w,h)
|
||||||
|
|
||||||
prott1 = r'ML-Models\MobileNetSSD_deploy.prototxt'
|
prott1 = r'ML-Models/MobileNetSSD_deploy.prototxt'
|
||||||
prott2 = r'ML-Models\MobileNetSSD_deploy.caffemodel'
|
prott2 = r'ML-Models/MobileNetSSD_deploy.caffemodel'
|
||||||
net = cv2.dnn.readNetFromCaffe(prott1, prott2)
|
net = cv2.dnn.readNetFromCaffe(prott1, prott2)
|
||||||
|
|
||||||
CLASSES = ["person"]
|
CLASSES = ["person"]
|
||||||
@ -129,13 +135,17 @@ while True:
|
|||||||
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
|
box = detections[0, 0, i, 3:7] * np.array([w, h, w, h])
|
||||||
(startX, startY, endX, endY) = box.astype("int")
|
(startX, startY, endX, endY) = box.astype("int")
|
||||||
# draw the prediction on the frame
|
# draw the prediction on the frame
|
||||||
label = "{}: {:.2f}%".format(CLASSES[idx],
|
|
||||||
confidence * 100)
|
#label = "{}: {:.2f}%".format(CLASSES[idx], confidence * 100)
|
||||||
cv2.rectangle(frame, (startX, startY), (endX, endY),
|
label = "{}: {:.2f}%".format(CLASSES[0], confidence * 100)
|
||||||
COLORS[idx], 2)
|
|
||||||
|
#cv2.rectangle(frame, (startX, startY), (endX, endY), COLORS[idx], 2)
|
||||||
|
cv2.rectangle(frame, (startX, startY), (endX, endY), COLORS[0], 2)
|
||||||
|
|
||||||
y = startY - 15 if startY - 15 > 15 else startY + 15
|
y = startY - 15 if startY - 15 > 15 else startY + 15
|
||||||
cv2.putText(frame, label, (startX, y),
|
|
||||||
cv2.FONT_HERSHEY_SIMPLEX, 0.5, COLORS[idx], 2)
|
#cv2.putText(frame, label, (startX, y), cv2.FONT_HERSHEY_SIMPLEX, 0.5, COLORS[idx], 2)
|
||||||
|
cv2.putText(frame, label, (startX, y), cv2.FONT_HERSHEY_SIMPLEX, 0.5, COLORS[0], 2)
|
||||||
|
|
||||||
cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 255, 0), 2)
|
cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 255, 0), 2)
|
||||||
# Start tracker
|
# Start tracker
|
||||||
@ -183,8 +193,7 @@ while True:
|
|||||||
# draw the text and timestamp on the frame
|
# draw the text and timestamp on the frame
|
||||||
now2 = datetime.now()
|
now2 = datetime.now()
|
||||||
time_passed_seconds = str((now2-now).seconds)
|
time_passed_seconds = str((now2-now).seconds)
|
||||||
cv2.putText(frame, 'Detecting persons',(10, 20),
|
cv2.putText(frame, 'Detecting persons',(10, 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
|
||||||
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
|
|
||||||
|
|
||||||
# show the frame and record if the user presses a key
|
# show the frame and record if the user presses a key
|
||||||
cv2.imshow("Video stream", frame)
|
cv2.imshow("Video stream", frame)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user