-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_cand.py
142 lines (103 loc) · 4.39 KB
/
add_cand.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
import sqlite3
import tkinter as tk
# from tkinter import *
from tkinter import messagebox as ms
import sqlite3
from PIL import Image, ImageTk
import re
import random
from tkinter.filedialog import askopenfilename
import os
import cv2
global id
window = tk.Tk()
w, h = window.winfo_screenwidth(), window.winfo_screenheight()
window.geometry("%dx%d+0+0" % (w, h))
window.title(" FORM")
window.configure(background="grey")
global file
Fullname = tk.StringVar()
sym = tk.StringVar()
file1=tk.StringVar()
sym_name = tk.StringVar()
value = random.randint(1, 1000)
print(value)
image2 = Image.open('im1.jpg')
image2 = image2.resize((w, h), Image.ANTIALIAS)
background_image = ImageTk.PhotoImage(image2)
background_label = tk.Label(window, image=background_image)
background_label.image = background_image
background_label.place(x=0, y=0) # , relwidth=1, relheight=1)
frame_alpr = tk.LabelFrame(window, text=" --Process-- ", width=600, height=450, bd=5, font=('times', 15, ' bold '),bg="pink")
frame_alpr.grid(row=0, column=0, sticky='nw')
frame_alpr.place(x=400, y=150)
def show():
global file
file = askopenfilename(initialdir=r'D:/new/Smart_Voting_System/img', title='Select Image',
filetypes=[("all files", "*.*")])
image3 =Image.open(file)
image3 =image3.resize((450,280), Image.ANTIALIAS)
print(file)
return file
def convertToBinaryData(filename): #We have to add image to database thats why use this function to convert image into binary format
# Convert digital data to binary format
with open(filename, 'rb') as file:
blobData = file.read()
return blobData
def insertBLOB():
global file
fname = Fullname.get()
#un = username.get()
sym = file
Photo = convertToBinaryData(sym)
print(sym)
sym_n = sym_name.get()
try:
sqliteConnection = sqlite3.connect('upload_cad.db')
cursor = sqliteConnection.cursor()
print("Connected to SQLite")
sqlite_insert_blob_query = """ INSERT INTO cand
(Name, symbol, sym_name)
VALUES (?,?,?)"""
empPhoto = convertToBinaryData(sym)
#resume = convertToBinaryData(resumeFile)
# Convert data into tuple format
data_tuple = (fname,empPhoto,sym_n)
cursor.execute(sqlite_insert_blob_query, data_tuple)
sqliteConnection.commit()
print("Image and file inserted successfully as a BLOB into a table")
cursor.close()
except sqlite3.Error as error:
print("Failed to insert blob data into sqlite table", error)
finally:
if sqliteConnection:
sqliteConnection.close()
print("the sqlite connection is closed")
ms.showinfo("Driver Licence Record","Registration Completed !!")
window.destroy()
from subprocess import call
call(['python','face_data.py'])
#insertBLOB(1, "Smith", "E:/Number_plate_recognization/profile images/1.jpg")
# #insertBLOB(2, "David", "E:/Number_plate_recognization/profile images/2.jpg")
l1 = tk.Label(window, text="Add Candidate Form", font=("Times new roman", 30, "bold"), bg="Black", fg="white")
l1.place(x=500, y=5)
# that is for label1 registration
l2 = tk.Label(frame_alpr, text="Full Name :", width=12, font=("Times new roman", 15, "bold"), bg="snow")
l2.place(x=50, y=50)
t1 = tk.Entry(frame_alpr, textvar=Fullname, width=20, font=('', 15))
t1.place(x=300, y=50)
# that is for label 2 (full name)
l4 = tk.Button(frame_alpr, text="Upload Photo :", width=12, font=("Times new roman", 15, "bold"), bg="snow",command=show)
l4.place(x=50, y=150)
#file1=show(file)
#t3 = tk.Entry(window, textvar=file1, width=20, font=('', 15))
#t3.place(x=330, y=450)
l10 = tk.Label(frame_alpr, text="Symbol Name", width=15, font=("Times new roman", 15, "bold"), bg="snow")
l10.place(x=50, y=250)
t10 = tk.Entry(frame_alpr, textvar=sym_name, width=20, font=('', 15))
t10.place(x=300, y=250)
btn = tk.Button(frame_alpr, text="Submit", bg="red",font=("",20),fg="white", width=9, height=1, command=insertBLOB)
btn.place(x=260, y=350)
# tologin=tk.Button(window , text="Go To Login", bg ="dark green", fg = "white", width=15, height=2, command=login)
# tologin.place(x=330, y=600)
window.mainloop()