Skip to content

Commit

Permalink
updated version of facial recognition
Browse files Browse the repository at this point in the history
  • Loading branch information
abhimanyuthakre committed Jul 10, 2018
2 parents 28870a3 + 662a9b4 commit a5d3d2f
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 12 deletions.
20 changes: 9 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

A digital assistant for your device that uses speech-recognition to obey your commands

NOTE: B.E.N.J.I. has been selected as a project for the [Kharagpur Winter of Code 2017](https://kwoc.kossiitkgp.in/) :tada:
NOTE #1: B.E.N.J.I. has participated in the following Open-Source Programs: Kharagpur Winter of Code 2017 and GirlScript Summer Of Code 2018. :tada:

NOTE #2: I was invited to talk about B.E.N.J.I at the [Open-Source Summit held at IIT Kharagpur](https://kwoc.kossiitkgp.in/summit) on the 21st of January 2018. You can view the slides [here](https://github.com/the-ethan-hunt/B.E.N.J.I./blob/master/OSS_IIT_KGP_Dhruv_Apte.pdf). The video session is available to watch [here](https://www.youtube.com/watch?v=dydyiqR49KE&list=PLzumvJj1-3nDRq6Le2bFSmbtz0g7CppKb&index=11) :tada:
NOTE #2: I was invited to talk about B.E.N.J.I at the Open-Source Summit held at IIT Kharagpur on the 21st of January 2018. You can view the slides [here](https://github.com/the-ethan-hunt/B.E.N.J.I./blob/master/OSS_IIT_KGP_Dhruv_Apte.pdf). The video session is available to watch [here](https://www.youtube.com/watch?v=dydyiqR49KE&list=PLzumvJj1-3nDRq6Le2bFSmbtz0g7CppKb&index=11) :tada:

### List of contents

Expand All @@ -32,7 +32,7 @@ NOTE #2: I was invited to talk about B.E.N.J.I at the [Open-Source Summit held a
- [FAQs](#faqs)
- [License](#license)

### Declassified debrief
### Declassified debrief

[(Back to top)](#list-of-contents)

Expand All @@ -59,7 +59,7 @@ P.S. B.E.N.J.I. now works for Windows, Linux and Mac OS :tada:
^~~~~~~~~~~~~
1 error generated.
error: command 'clang' failed with exit status 1
----------------------------------------
Command "/usr/local/opt/python3/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/fv/cy3_1czs31q64478bzxd7_m5vdlrd8/T/pip-build-z73z9sim/PyAudio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/fv/cy3_1czs31q64478bzxd7_m5vdlrd8/T/pip-wh091sp7-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/fv/cy3_1czs31q64478bzxd7_m5vdlrd8/T/pip-build-z73z9sim/PyAudio/
You are using pip version 9.0.1, however version 10.0.1 is available.
Expand All @@ -78,9 +78,9 @@ Command to solve the above: ```pip3 install Pillow```
Change the pip version above according to what you have installed on your mac.

### B.E.N.J.I working in Linux
![Working in Linux](working-benjion-linux.gif)
![Working in Linux](working-benjion-linux.gif)

### B.E.N.J.I working on Windows
### B.E.N.J.I working on Windows
![Working on Windows](working-benji-windows.gif)

### Contributing
Expand All @@ -93,9 +93,9 @@ Contributions are welcomed heartily; any new `feature` or a `bug fix` is great!

[(Back to top)](#list-of-contents)

1. How to use B.E.N.J.I. to open a website/webpage?
* Say "facebook.com" and B.E.N.J.I. will open the requested page. Here, it's important to specify the top-level domain i.e. ".com".
2. How to use the news feature?
1. How to use B.E.N.J.I. to open a website/webpage?
* Say "facebook.com" and B.E.N.J.I. will open the requested page. Here, it's important to specify the top-level domain i.e. ".com".
2. How to use the news feature?
* Say "news the hindu" and B.E.N.J.I. will open list of latest "news" by requested news agency.
3. How to use the recording feature? (Windows)
* "UScreenCapture" and "ffmpeg" needed to run this feature.
Expand All @@ -105,5 +105,3 @@ Contributions are welcomed heartily; any new `feature` or a `bug fix` is great!
[(Back to top)](#list-of-contents)

The MIT License 2017 - [Dhruv Apte](http://github.com/the-ethan-hunt/).


4 changes: 4 additions & 0 deletions windows/activities.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ List of the things that B.E.N.J.I. can do:
* mp4 - avi, mkv, webm
* Images to video
* Search for a file on your Device
* Add event in your Google Calendar
* Play Youtube videos
* Download video
* Download music
Expand Down Expand Up @@ -101,6 +102,9 @@ NOTE: Try different expression to make B.E.N.J.I. more secure. Make sure to make
NOTE: All the recorded files will be saved on the desktop. Make sure that the file names should not be same. "input.avi" and "input.mp3" have no conflicts. But "input.avi" and "input.avi" will result into conflicts.
* "***images to video*** _time_". Here time is the display time of each image. For this feature to run, you should create a folder "Images" on desktop. Add the images to the folder and rename them as "img001.jpg", "img002.jpg" and so on. After running the command, you will get the video in the same folder in ".avi" format.
* "***lookfor/find*** _Filename_ _PathWhereYouWantToSearch_" to look for a file at a specified location and open it. Also you can open files from C drive, D drive, Desktop, Documents, Downloads by saying- find/lookfor in <C or D drive/Documents/Desktop?downloads>. C and D drive can be opened by saying- lookfor/find C/D drive(Version: Microsoft Windows [Version 10.0.16299.431]).
* "***draw graph for*** _formula_ ***from*** _Upper-limit_ ***to*** _Lower-limit_" to plot graph for formula like(x^n+ax^m+b ...) for example,
_draw graph for x**2+4*x+6 from -100 to 100_.
* "***add event in google calendar*** to add event on your google calendar, type(or say) in the following format: "add event <event_name> <start date in format yyyy-mm-dd> to <end date in format yyyy-mm-dd>" and it will save the event on your google calendar.
* "***play/stream/queue*** _Song/VideoName_" to play any song or video on Youtube.
* "***download video*** _SongName_" to download video.
* "***download music*** _SongName_" to download a song.
Expand Down
149 changes: 149 additions & 0 deletions windows/benji.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# coding: utf-8
from __future__ import print_function
import tkinter as tk
from tkinter import ttk
import wx
import regex
import os
import pyautogui
import wikipedia
import time
import webbrowser
Expand All @@ -14,6 +16,7 @@
import ctypes
import random
import urllib
import datetime
import ssl
from bs4 import BeautifulSoup
import win32com.client as wicl
Expand All @@ -29,6 +32,15 @@
from pytube import YouTube
import face_recognition
import cv2
import matplotlib.pyplot as plt
import numpy as np
import httplib2
import os
from apiclient import discovery
from oauth2client import client
from oauth2client import tools
from oauth2client.file import Storage
import datetime

requests.packages.urllib3.disable_warnings()
try:
Expand All @@ -52,6 +64,7 @@ def events(frame,put):
check_keywords = ["what","when","was","how","has","had","should","would","can","could","cool","good"] #could or cool or good
download_music=("download ","download music ")
search_pc= ("find ","lookfor ")
graph_generation = ("draw graph for ")
close_keywords=("close ","over ","stop ","exit ")
pc_locations = ("desktop", "documents", "downloads")

Expand All @@ -68,6 +81,56 @@ def events(frame,put):
cam.release()
cv2.destroyAllWindows()

#Screenshot
elif put.startswith('take screenshot') or put.startswith("screenshot"):
try:
pic = pyautogui.screenshot()
spath = os.path.expanduser('~') + '/Desktop/screenshot.jpg'
pic.save(spath)
except:
print("Unable to take screenshot.")

#Upcoming events
elif put.startswith("upcoming events") or put.startswith("coming events") or put.startswith("events"):
try:
SCOPES = 'https://www.googleapis.com/auth/calendar.readonly'
store = file.Storage('credentials.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets('client_secret.json', SCOPES)
creds = tools.run_flow(flow, store)
service = build('calendar', 'v3', http=creds.authorize(Http()))

now = datetime.datetime.utcnow().isoformat() + 'z' # 'Z' indicates UTC time
root = tk.Tk()
root.title("Top 10 Upcoming Events")

events_result = service.events().list(calendarId='primary', timeMin=now,maxResults=10, singleEvents=True,orderBy='startTime').execute()
events = events_result.get('items', [])

if not events:
w = tk.Label(root, text="No upcoming events found.")
w.pack()

w = tk.Label(root, text="Event Title")
w.grid(row=0, column=1)
w = tk.Label(root, text="Time And Date Of Event")
w.grid(row=0, column=2)

i=1
for event in events:
start = event['start'].get('dateTime', event['start'].get('date'))
w = tk.Label(root, text=event['summary'])
w.grid(row=i, column=1)
w = tk.Label(root, text=start)
w.grid(row=i, column=2)
i=i+1

root.geometry("400x400")
root.mainloop()
except:
print("Unable to take upcoming events")

#Add note
elif put.startswith("note") or put.startswith("not") or put.startswith("node"):
try:
Expand All @@ -89,6 +152,73 @@ def events(frame,put):
speak.runAndWait()
except:
print("Could not add the specified note!")

#adding an event in google calendar
elif link[0] == "add" and link[1]=="event":
try:
try:
import argparse
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args()
except ImportError:
flags = None

SCOPES = 'https://www.googleapis.com/auth/calendar'
CLIENT_SECRET_FILE = 'Client_Secret.json'
APPLICATION_NAME = 'GSSOC '

def get_credentials():
home_dir = os.path.expanduser('~')
credential_dir = os.path.join(home_dir, '.credentials')
if not os.path.exists(credential_dir):
os.makedirs(credential_dir)
credential_path = os.path.join(credential_dir,'calendar-python-quickstart.json')
store = Storage(credential_path)
credentials = store.get()
if not credentials or credentials.invalid:
flow = client.flow_from_clientsecrets(CLIENT_SECRET_FILE, SCOPES)
flow.user_agent = APPLICATION_NAME
if flags:
credentials = tools.run_flow(flow, store, flags)
else:
credentials = tools.run(flow, store)
print('Storing credentials to ' + credential_path)
return credentials

def main():
credentials = get_credentials()
http = credentials.authorize(httplib2.Http())
service = discovery.build('calendar', 'v3', http=http)
summary = link[2]
d = link[-3]
e = link[-1]
date = d+"T00:00:00-07:00"
end = e+"T00:00:00-07:00"
event = {
'summary': summary,
'start': {
'dateTime': date,
},
'end': {
'dateTime': end,
},
'reminders': {
'useDefault': False,
'overrides': [
{'method': 'email', 'minutes': 24 * 60},
{'method': 'popup', 'minutes': 15},
],
},
}

event = service.events().insert(calendarId='primary', body=event).execute()
#print('Event created: %s' % (event.get('htmlLink')))
#webbrowser.open('https://calendar.google.com/calendar/r')

if __name__ == '__main__':
main()

except Exception as e:
print(e)
#Open a existing folder
elif put.startswith(search_pc):
try:
Expand Down Expand Up @@ -227,6 +357,8 @@ def events(frame,put):
speak.runAndWait()
except:
print("Unable to create video file!")

#Open Files
elif put.startswith(search_pc):
try:
name=link[1]
Expand All @@ -243,6 +375,23 @@ def events(frame,put):
except:
print("Error")

#Plotting of graph
elif put.startswith(graph_generation):
try:
formula = link[3]
lower_limit = int(link[5])
upper_limit = int(link[7])
x = np.array(range(lower_limit,upper_limit))
y = eval(formula)
speak.say("Plotting The Graph")
speak.runAndWait()
plt.plot(x, y)
plt.show()
except:
print("Error")
speak.say("Sorry Graph can not be Plotted")
speak.runAndWait()

# elif put.startswith(search_pc):
# process=subprocess.Popen("dir /b/s "+link[1],shell=True,stdout=subprocess.PIPE)
# while True:
Expand Down
1 change: 1 addition & 0 deletions windows/client_secret.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"installed":{"client_id":"722399897481-v76kg1sml6o55op08kpi7ksf5h1fhb98.apps.googleusercontent.com","project_id":"algebraic-creek-207209","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://accounts.google.com/o/oauth2/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"VO-i1I4bMRaXEbBVB0aqWaPt","redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"]}}
Empty file added windows/credentials.json
Empty file.
13 changes: 12 additions & 1 deletion windows/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
apiclient==1.0.3
beautifulsoup4==4.6.0
certifi==2017.11.5
chardet==3.0.4
client==0.0.1
cmake=3.11.0
colorama==0.3.9
data==0.4
decorator==4.1.2
dlib=19.14.0
face-recognition==1.2.2
funcsigs==1.0.2
future==0.16.0
google-api-python-client
httplib2==0.11.3
idna==2.6
ipython==6.2.1
ipython-genutils==0.2.0
jedi==0.11.0
latex==0.7.0
mpmath==1.0.0
matplotlib
numpy==1.13.3
opencv-python==3.4.1.15
opencv-contrib-python==3.4.1.15
oauth2client==4.1.2
pandas==0.21.0
parso==0.1.0
pickleshare==0.7.4
prompt-toolkit==1.0.15
PyAudio==0.2.11
#incase pyAudio blows up first install portaudio19-dev and then try installing pyaudio
PyAutoGUI==0.9.36
Pygments==2.2.0
pypiwin32==219
pypiwin32
python-dateutil==2.6.1
python-pptx==0.6.7
pyttsx3==2.7
Expand Down

0 comments on commit a5d3d2f

Please sign in to comment.