-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patha.py
More file actions
31 lines (28 loc) · 902 Bytes
/
Copy patha.py
File metadata and controls
31 lines (28 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cv2 as cv
import numpy as np
video = cv.VideoCapture("a.mp4")
car_cascade = cv.CascadeClassifier('cars.xml')
while True:
check, frame = video.read()
frame = cv.resize(frame, (640,480))
copy = cv.resize(frame,(640,480))
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
cars = car_cascade.detectMultiScale(gray,1.1,3)
for(x,y,w,h) in cars:
cv.rectangle(copy, (x, y), (x+w, y+h), (255, 255, 255),-1)
cv.rectangle(frame, (x, y), (x+w, y+h), (255, 255, 255),-1)
rows = copy.shape[0]
cols = copy.shape[1]
for i in range(rows):
for j in range(cols):
if np.array_equal(copy[i,j],[255,255,255]):
pass
else:
copy[i,j] = [0,0,0]
cv.imshow("frame",frame)
cv.imshow("copy",copy)
k = cv.waitKey(5) & 0xFF
if k == 27:
break
cv.destroyAllWindows()
video.release()