This file contains hidden or 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 cv2 | |
import numpy as np | |
min_contour_width = 40 | |
min_contour_height = 40 | |
offset = 10 | |
line_height = 550 | |
matches = [] | |
cars = 0 | |
This file contains hidden or 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
while ret: | |
d = cv2.absdiff(frame1, frame2) | |
grey = cv2.cvtColor(d, cv2.COLOR_BGR2GRAY) | |
blur = cv2.GaussianBlur(grey, (5, 5), 0) | |
ret, th = cv2.threshold(blur, 20, 255, cv2.THRESH_BINARY) | |
dilated = cv2.dilate(th, np.ones((3, 3))) | |
kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (2, 2)) |
This file contains hidden or 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 cv2 | |
#img = cv2.imread('/home/pyarena/python/OpenCV/objectDetection/image1.jpg') | |
cap = cv2.VideoCapture(-1) | |
cap.set(3, 640)# | |
cap.set(4, 480)# | |
classNames = [] | |
This file contains hidden or 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
while True: # | |
success, img = cap.read() # | |
classIds, confs, bbox = net.detect(img, confThreshold=0.5) | |
print(classIds, bbox) | |
if len(classIds) != 0: # | |
for classId, confidence, box in zip(classIds.flatten(), confs.flatten(), bbox): | |
cv2.rectangle(img, box, color=(0, 255, 0), thickness=2) | |
cv2.putText(img, classNames[classId-1].upper(), (box[0]+10, box[1]+30), cv2.FONT_HERSHEY_COMPLEX, 1, (0,255,0), 2) |
This file contains hidden or 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 cv2 | |
import mediapipe as mp | |
import time | |
class FaceDetector(): | |
def __init__(self, minDetectionCon=0.5): |
This file contains hidden or 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 cv2 | |
import mediapipe as mp | |
import time | |
cap = cv2.VideoCapture('/home/python/OpenCV/faceDetect/faceD1.mp4') | |
#cap = cv2.VideoCapture(0) |
This file contains hidden or 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
while True: | |
success, img = cap.read() | |
imgRGB = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) | |
results = faceDetection.process(imgRGB) | |
if results.detections: | |
for id, detection in enumerate(results.detections): | |
mpDrawing.draw_detection(img, detection) | |
#print(id, detection) |
This file contains hidden or 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
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous"> |