initial commit. original pre-2020 (Freshman Year)
This commit is contained in:
commit
eddbc487b6
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
formatted_thots
|
||||
saved_thots
|
||||
thots
|
||||
thots_false
|
2
ard.aliases
Normal file
2
ard.aliases
Normal file
@ -0,0 +1,2 @@
|
||||
[My Computer]
|
||||
My Computer="localhost"
|
12
ard.ini
Normal file
12
ard.ini
Normal file
@ -0,0 +1,12 @@
|
||||
[ard]
|
||||
server.app.propertiesEnabled=True
|
||||
server.ole.enabled=True
|
||||
server.tcp.paranoid=True
|
||||
server.tcp.serviceName="My Computer/VI Server"
|
||||
server.vi.callsEnabled=True
|
||||
server.vi.propertiesEnabled=True
|
||||
WebServer.TcpAccess="c+*"
|
||||
WebServer.ViAccess="+*"
|
||||
DebugServerEnabled=False
|
||||
DebugServerWaitOnLaunch=False
|
||||
|
BIN
begone_thot.mp3
Normal file
BIN
begone_thot.mp3
Normal file
Binary file not shown.
BIN
begone_thot.wav
Normal file
BIN
begone_thot.wav
Normal file
Binary file not shown.
33314
face_cascade.xml
Normal file
33314
face_cascade.xml
Normal file
File diff suppressed because it is too large
Load Diff
0
female_downloader.py
Normal file
0
female_downloader.py
Normal file
12
grayscaler.py
Normal file
12
grayscaler.py
Normal file
@ -0,0 +1,12 @@
|
||||
import cv2
|
||||
import os
|
||||
|
||||
lines = ""
|
||||
for file_name in os.listdir("thots_false"):
|
||||
path = "thots_false/" + file_name
|
||||
img = cv2.imread(path, cv2.IMREAD_GRAYSCALE)
|
||||
#cv2.imwrite(path, img)
|
||||
lines += path+ "\n"
|
||||
f = open("thots_false/bg.txt", "w")
|
||||
f.write(lines)
|
||||
f.close()
|
38
not_thot_downloader.py
Normal file
38
not_thot_downloader.py
Normal file
@ -0,0 +1,38 @@
|
||||
import urllib.request
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
import os
|
||||
|
||||
def store_raw_images():
|
||||
blank_img = cv2.imread("thots_false/blank.jpg", cv2.IMREAD_GRAYSCALE)
|
||||
|
||||
#thots
|
||||
#lnk = "http://www.image-net.org/api/text/imagenet.synset.geturls?wnid=n09972458"
|
||||
#not thots
|
||||
#lnk = "http://www.image-net.org/api/text/imagenet.synset.geturls?wnid=n00017222"
|
||||
lnk = "http://www.image-net.org/api/text/imagenet.synset.geturls?wnid=n04081281"
|
||||
neg_image_urls = urllib.request.urlopen(lnk).read().decode()
|
||||
n = 1273
|
||||
for image_url in neg_image_urls.split("\n"):
|
||||
try:
|
||||
n += 1
|
||||
if n >= 2000:
|
||||
break
|
||||
path = "thots_false/" + str(n) + ".jpg"
|
||||
print("\n")
|
||||
print(str(n) + "/" + str(len(neg_image_urls.split("\n"))))
|
||||
print(image_url)
|
||||
urllib.request.urlretrieve(image_url, path)
|
||||
img = cv2.imread(path, cv2.IMREAD_GRAYSCALE)
|
||||
if (img.shape == blank_img.shape):
|
||||
print("Blank Image Detected, deleting...")
|
||||
os.remove(path)
|
||||
continue
|
||||
rs_img = cv2.resize(img, (100, 100))
|
||||
cv2.imwrite("thots_false/" + str(n) + ".jpg", rs_img)
|
||||
print("Success")
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
store_raw_images()
|
1328
thot_cascade.xml
Normal file
1328
thot_cascade.xml
Normal file
File diff suppressed because it is too large
Load Diff
66
thot_detector.py
Normal file
66
thot_detector.py
Normal file
@ -0,0 +1,66 @@
|
||||
#code modified from https://pythonprogramming.net/haar-cascade-object-detection-python-opencv-tutorial/
|
||||
|
||||
import numpy as np
|
||||
import cv2
|
||||
import os
|
||||
|
||||
from pygame import mixer
|
||||
|
||||
mixer.init()
|
||||
mixer.music.load("begone_thot.mp3")
|
||||
|
||||
thot_cascade = cv2.CascadeClassifier('face_cascade.xml')
|
||||
|
||||
cap = cv2.VideoCapture(0)
|
||||
|
||||
launched = False
|
||||
capturing = False
|
||||
saved = 0
|
||||
recent_saved = 0
|
||||
|
||||
while True:
|
||||
ret, img = cap.read()
|
||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||
|
||||
# add this
|
||||
# image, reject levels level weights.
|
||||
thots = thot_cascade.detectMultiScale(gray, 1.3, 5)
|
||||
|
||||
# add this
|
||||
for (x,y,w,h) in thots:
|
||||
#speech.say("Thought Detected")
|
||||
#speech.runAndWait()
|
||||
font = cv2.FONT_HERSHEY_SIMPLEX
|
||||
if not launched:
|
||||
pass
|
||||
#os.system("ard.exe")
|
||||
capturing = True
|
||||
recent_saved = 0
|
||||
if (not mixer.music.get_busy()):
|
||||
mixer.music.play()
|
||||
cv2.putText(img, 'THOT',(x+w,y+h), font, 0.5, (11,255,255), 2, cv2.LINE_AA)
|
||||
cv2.rectangle(img,(x,y),(x+w,y+h),(255,255,0),2)
|
||||
if capturing and recent_saved < 60:
|
||||
cv2.imwrite("M:/Pictures/saved_thots/detected_thot_" + str(saved) + ".jpg", img)
|
||||
saved += 1
|
||||
recent_saved += 1
|
||||
|
||||
"""
|
||||
for (x,y,w,h) in faces:
|
||||
cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2)
|
||||
|
||||
|
||||
roi_gray = gray[y:y+h, x:x+w]
|
||||
roi_color = img[y:y+h, x:x+w]
|
||||
eyes = eye_cascade.detectMultiScale(roi_gray)
|
||||
for (ex,ey,ew,eh) in eyes:
|
||||
cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2)
|
||||
"""
|
||||
|
||||
cv2.imshow('Thot Detector',img)
|
||||
k = cv2.waitKey(30) & 0xff
|
||||
if k == 27:
|
||||
break
|
||||
|
||||
cap.release()
|
||||
cv2.destroyAllWindows()
|
28
thot_detector_from_input.py
Normal file
28
thot_detector_from_input.py
Normal file
@ -0,0 +1,28 @@
|
||||
#code modified from https://pythonprogramming.net/haar-cascade-object-detection-python-opencv-tutorial/
|
||||
|
||||
import numpy as np
|
||||
import cv2
|
||||
import os
|
||||
|
||||
thot_cascade = cv2.CascadeClassifier('face_cascade.xml')
|
||||
|
||||
launched = False
|
||||
capturing = False
|
||||
saved = 0
|
||||
recent_saved = 0
|
||||
|
||||
img = cv2.imread("IMG_2619.jpg", 0)
|
||||
print(img)
|
||||
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||
thots = thot_cascade.detectMultiScale(gray, 1.3, 5)
|
||||
for (x,y,w,h) in thots:
|
||||
font = cv2.FONT_HERSHEY_SIMPLEX
|
||||
if not launched:
|
||||
pass
|
||||
#os.system("ard.exe")
|
||||
capturing = True
|
||||
recent_saved = 0
|
||||
cv2.putText(img, 'THOT',(x+w,y+h), font, 0.5, (11,255,255), 2, cv2.LINE_AA)
|
||||
cv2.rectangle(img,(x,y),(x+w,y+h),(255,255,0),2)
|
||||
cv2.imwrite("detected_thot_" + str(saved) + ".jpg", img)
|
||||
|
Loading…
Reference in New Issue
Block a user