aboutsummaryrefslogtreecommitdiffstats
path: root/get_images.py
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2020-08-25 03:27:52 +0100
committerjwansek <eddie.atten.ea29@gmail.com>2020-08-25 03:27:52 +0100
commita1eca9b3526593d29b03300000e3b597a62e37b3 (patch)
treeb5e15c2fb79602fbcfe58a4f8d6982fc0a497858 /get_images.py
parent728f9f3b0a35d1dd66f15ef5f159d5bc8d4b85e2 (diff)
downloadyaoi-communism-a1eca9b3526593d29b03300000e3b597a62e37b3.tar.gz
yaoi-communism-a1eca9b3526593d29b03300000e3b597a62e37b3.zip
added facial recognision
Diffstat (limited to 'get_images.py')
-rw-r--r--get_images.py30
1 files changed, 25 insertions, 5 deletions
diff --git a/get_images.py b/get_images.py
index 08a17e3..b4fef24 100644
--- a/get_images.py
+++ b/get_images.py
@@ -83,14 +83,34 @@ class DownloadedImage:
def __exit__(self, type, value, traceback):
os.remove(self.filename)
-if __name__ == "__main__":
- # print(get_image(get_random_searchtag()))
+def main():
+ try:
+ simg = get_image(get_random_searchtag())
+ except ConnectionError:
+ main()
- simg = get_image(get_random_searchtag())
with DownloadedImage(simg.imurl) as impath:
img = cv2.imread(impath)
- cv2.imshow("img, ", img)
- cv2.waitkey(0)
+ cascade = cascade = cv2.CascadeClassifier(os.path.join("lbpcascade_animeface", "lbpcascade_animeface.xml"))
+ gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
+ gray = cv2.equalizeHist(gray)
+
+ faces = cascade.detectMultiScale(gray,
+ # detector options
+ scaleFactor = 1.1,
+ minNeighbors = 5,
+ minSize = (24, 24))
+ for (x, y, w, h) in faces:
+ cv2.rectangle(img, (x, y), (x + w, y + h), (0, 0, 255), 2)
+
+ cv2.imshow("Press <q> to exit", img)
+ cv2.waitKey(0)
+
+if __name__ == "__main__":
+ main()
+
+
+