Created
May 5, 2019 19:29
-
-
Save lol97/bfb80b82cf38dc1059557542415eb6a8 to your computer and use it in GitHub Desktop.
Code Iseng #1
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
| ''' | |
| Cat Faces Detection | |
| Sufyan Saori | |
| ''' | |
| import cv2 | |
| cascade_path = "..." #change to your cascade path | |
| cat_cascade = cv2.CascadeClassifier(cascade_path) | |
| path_img = "..." #change to your image path | |
| img = cv2.imread(path_img) | |
| img_gray = cv2.cvtColor (img, cv2.COLOR_BGR2GRAY) | |
| faces = cat_cascade.detectMultiScale(img, scaleFactor=1.3, | |
| minNeighbors=2, minSize=(20, 20)) | |
| for i, (x, y, w, h) in enumerate(faces) : | |
| cv2.rectangle(img, (x,y), (x+w, y+h), (255,0,0), 2) | |
| cv2.putText(img, "Cat #{}".format(i + 1), (x, y - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.55, (0, 0, 255), 2) | |
| cv2.imshow('cat faces', img) | |
| cv2.waitKey() | |
| cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment