Commit 74f98d8d authored by Vikrant Rajan's avatar Vikrant Rajan
Browse files

motion detection

parents
Pipeline #160 canceled with stages
{
"python.linting.pylintEnabled": true
}
\ No newline at end of file
# SECTION 1
# import datetime
# print("The date and time is: ", datetime.datetime.now())
# SECTION 2
# import datetime
# nowDate = datetime.datetime.now()
# myNumber = 10
# myText = "Hello"
# print(nowDate, myNumber, myText)
# SECTION 3
numbers = [123, 1234.34, 123.45]
print(numbers.count(123))
class Account:
def __init__(self, filepath):
self.filepath=filepath
with open(filepath, 'r') as file:
self.balance = float(file.read())
def withdraw(self, amount):
self.balance = self.balance - amount
def deposit(self, amount):
self.balance = self.balance + amount
def commit(self):
with open(self.filepath, 'w') as file:
file.write(str(self.balance))
class Chequing(Account):
def __init__(self, filepath, fee):
Account.__init__(self, filepath)
self.fee = fee
def transfer(self, amount):
self.balance = self.balance - amount - self.fee
# account = Account("balance.txt")
chequing = Chequing("balance.txt", 3.99)
print(chequing.balance)
# chequing.deposit(4000)
chequing.transfer(3300)
chequing.commit()
print(chequing.balance)
\ No newline at end of file
6396.01
\ No newline at end of file
python-sqllite-database-app @ 5145acd2
Subproject commit 5145acd24a04b18ca111d7083f4b7e89db0263b2
{
"python.linting.pylintEnabled": true
}
\ No newline at end of file
import json
from difflib import get_close_matches
data = json.load(open("data.json"))
def translate(w):
w = w.lower()
if w in data:
return data[w]
elif w.title() in data:
return data[w.title()]
elif w.upper() in data: #in case user enters words like USA or NATO
return data[w.upper()]
elif len(get_close_matches(w, data.keys())) > 0:
yn = input("Did you mean %s instead? Enter Y if yes, or N if no: " % get_close_matches(w, data.keys())[0])
if yn == "Y":
return data[get_close_matches(w, data.keys())[0]]
elif yn == "N":
return "The word doesn't exist. Please double check it."
else:
return "We didn't understand your entry."
else:
return "The word doesn't exist. Please double check it."
word = input("Enter word: ")
output = translate(word)
if type(output) == list:
for item in output:
print(item)
else:
print(output)
\ No newline at end of file
This diff is collapsed.
import json
from difflib import get_close_matches
data = json.load(open("data.json"))
def definition(word):
word = word.lower()
if word in data:
return data[word]
elif len(get_close_matches(word, data.keys())) > 0:
# return "Did you mean %s instead" % get_close_matches(word, data.keys())[0]
yn = input(f"Did you mean... {get_close_matches(word, data.keys())[0]}? Enter Y if yes, or N if no.")
if yn == "Y":
return data[get_close_matches(word, data.keys())[0]]
elif yn == "N":
return "Can't help you."
else:
return ".......Bye?"
else:
return "Try something else"
word = input("Enter word: ")
output = definition(word)
if type(output) == list:
for item in output:
print(item)
else:
print(output)
\ No newline at end of file
import cv2
# IMPORTING FACE DETECTION FILE & CONVERTING IT TO GRAY CAUSE ITS MORE ACCURATE
face_cascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
img = cv2.imread("news.jpg")
gray_img = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray_img, scaleFactor=1.1, minNeighbors=5)
for x, y, w, h in faces:
# (x,y) LEFT TOP SIDE OF RECTANGLE
# (x+w,y+h) RIGHT BOTTOM SIDE OF RECTANGLE
# (0,255,0) RGB COLOR
# 3 THICKNESS OF STROKE
img = cv2.rectangle(img, (x,y), (x+w,y+h), (0,255,0), 3)
print(type(faces))
print(faces)
resized = cv2.resize(img,(int(img.shape[1]/3), int(img.shape[0]/3)))
cv2.imshow("Gray", resized)
cv2.waitKey(0)
cv2.destroyAllWindows()
\ No newline at end of file
Video Face Detection App @ abafb43a
Subproject commit abafb43a939140de3b1fde8832baf27c526eb11d
import cv2, time
video = cv2.VideoCapture(0)
a = 0
while True:
a = a+1
check, frame = video.read()
print(check)
print(frame)
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
time.sleep(3)
cv2.imshow("Capturing", gray)
key = cv2.waitKey(1)
if key == ord('q'):
break
print(a)
video.release()
cv2.destroyAllWindows
\ No newline at end of file
import cv2
# to read as is
# img=cv2.imread("galaxy.jpg", 1)
# Transparancy
# img=cv2.imread("galaxy.jpg", -1)
# Greyscale
img=cv2.imread("galaxy.jpg", 0)
# print(type(img))
# print(img)
# SIZE OF IMAGE shape[0] = Height shape[1] = Width
print(img.shape)
# DIMENSIONS OF IMAGE
print(img.ndim)
resized_image = cv2.resize(img, (int(img.shape[1]/2),int(img.shape[0]/2)))
cv2.imshow("Galaxy",resized_image)
cv2.imwrite("Galaxy_resized.jpg", resized_image)
cv2.waitKey(6000)
cv2.destroyAllWindows()
\ No newline at end of file
from tkinter import *
window=Tk()
def from_kg():
gram=float(e2_value.get())*1000
pound=float(e2_value.get())*2.20462
ounce=float(e2_value.get())*35.274
t1.delete("1.0", END)
t1.insert(END,gram)
t2.delete("1.0", END)
t2.insert(END,pound)
t3.delete("1.0", END)
t3.insert(END,ounce)
e1=Label(window,text="Kg")
e1.grid(row=0,column=0)
e2_value=StringVar()
e2=Entry(window,textvariable=e2_value)
e2.grid(row=0,column=1)
b1=Button(window,text="Convert",command=from_kg, background="black")
b1.grid(row=0,column=2)
t1=Text(window,height=5,width=20)
t1.grid(row=5,column=0)
t2=Text(window,height=5,width=20)
t2.grid(row=5,column=1)
t3=Text(window,height=5,width=20)
t3.grid(row=5,column=2)
window.mainloop()
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment