-
Notifications
You must be signed in to change notification settings - Fork 3
/
29_Resimden_Araba_Algilama.py
34 lines (28 loc) · 1.15 KB
/
29_Resimden_Araba_Algilama.py
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
32
33
34
""" -*- coding: utf-8 -*-
@author: omerkocadayi
https://github.com/omerkocadayi
https://www.linkedin.com/in/omerkocadayi/ """
import cv2
img = cv2.imread("car.jpg")
img1 = cv2.imread("car1.jpeg")
carCascade = cv2.CascadeClassifier("haarcascade\\car.xml")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
cars = carCascade.detectMultiScale(gray,
scaleFactor=1.05,
minNeighbors=4,
minSize=(60, 60),
flags=cv2.CASCADE_SCALE_IMAGE)
gray1 = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
cars1 = carCascade.detectMultiScale(gray1,
scaleFactor=1.03,
minNeighbors=3,
minSize=(60, 60),
flags=cv2.CASCADE_SCALE_IMAGE)
for (a,b,c,d) in cars:
cv2.rectangle(img, (a,b), (a+c, b+d), (0,255,255), 2)
for (a,b,c,d) in cars1:
cv2.rectangle(img1, (a,b), (a+c, b+d), (0,255,255), 2)
cv2.imshow("Image", img)
cv2.imshow("Image 1", img1)
cv2.waitKey(0)
cv2.destroyAllWindows()