Created
May 2, 2021 14:11
-
-
Save amboxer21/4eb7d04ef6542f28ee34fea4ec016c09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import cv2 | |
import time | |
import cvlib as cv | |
from cvlib.object_detection import draw_bbox | |
counter = 0 | |
fps = 24.0 | |
cap = cv2.VideoCapture(0) | |
cap.set(3,320) | |
cap.set(4,320) | |
fourcc = cv2.VideoWriter_fourcc(*'MJPG') | |
out = cv2.VideoWriter( | |
filename, | |
fourcc, fps, (int(cap.get(3)), int(cap.get(4))) | |
) | |
while(True): | |
counter += 1 | |
bbox, label, conf = str(), str(), str() | |
# Capture frame-by-frame | |
ret, frame = cap.read() | |
# Detect objects and draw on screen | |
if counter == 30: | |
counter = 0 | |
bbox, label, conf = cv.detect_common_objects(frame) | |
print(label) | |
if('person' and 'bottle') in label: | |
os.system('speaker-test -tsine -f1000 -l1') | |
#output_image = draw_bbox(frame, bbox, label, conf) | |
#`output_image = draw_bbox(im, bbox, label, conf) | |
#cv2.imshow('output',output_image) | |
#if cv2.waitKey(1) & 0xFF == ord('q'): | |
# break | |
# When everything done, release the capture | |
cap.release() | |
out.release() | |
#$cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment