Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def identificar_carros(imagem):
- cars_classifier = cv2.CascadeClassifier('classificadores/haarcascade_car.xml')
- gray = cv2.cvtColor(imagem, cv2.COLOR_BGR2GRAY)
- cars = cars_classifier.detectMultiScale(gray, 1.2, 3)
- for (x,y,w,h) in cars:
- roi = imagem[y:y+h, x:x+w]
- area = int(w) * int(h)
- cv2.rectangle(imagem, (x,y), (x+w,y+h), (127,0,255), 2)
- cv2.putText(imagem, "CARRO", (x,y-20), cv2.FONT_HERSHEY_PLAIN, 2, (0,0,255), 1)
- return imagem
- cam_capture = cv2.VideoCapture("videos/cars.avi")
- while True:
- ret, image_frame = cam_capture.read()
- if ret:
- image_frame = identificar_carros(image_frame)
- cv2.imshow("Faces", image_frame)
- if cv2.waitKey(1) == 13:
- break
- cam_capture.release()
- cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement