├── README.md ├── LiveRecognition.py ├── LiveRecognition1.py └── Main.py /README.md: -------------------------------------------------------------------------------- 1 | # Abnormal_Event_Detection -------------------------------------------------------------------------------- /LiveRecognition.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | import sys, fsdk, math, ctypes, time 3 | from fsdk import FSDK 4 | 5 | license_key = "fVrFCzYC5wOtEVspKM/zfLWVcSIZA4RNqx74s+QngdvRiCC7z7MHlSf2w3+OUyAZkTFeD4kSpfVPcRVIqAKWUZzJG975b/P4HNNzpl11edXGIyGrTO/DImoZksDSRs6wktvgr8lnNCB5IukIPV5j/jBKlgL5aqiwSfyCR8UdC9s=" 6 | 7 | if not fsdk.windows: 8 | print('The program is for Microsoft Windows.'); exit(1) 9 | import win 10 | 11 | trackerMemoryFile = "tracker70.dat" 12 | 13 | FONT_SIZE = 30 14 | 15 | print("Initializing FSDK... ", end='') 16 | FSDK.ActivateLibrary(license_key); 17 | FSDK.Initialize() 18 | print("OK\nLicense info:", FSDK.GetLicenseInfo()) 19 | 20 | FSDK.InitializeCapturing() 21 | print('Looking for video cameras... ', end='') 22 | camList = FSDK.ListCameraNames() 23 | 24 | if not camList: print("Please attach a camera."); 25 | print(camList[0]) # camList[0].devicePath 26 | 27 | camera = camList[0] # choose the first camera (0) 28 | print("using '%s'" % camera) 29 | formatList = FSDK.ListVideoFormats(camera) 30 | #print(*zip(range(len(formatList)), formatList), sep='\n') 31 | print(*formatList[0:5], sep='\n') 32 | if len(formatList)>5: print('...', len(formatList)-5, 'more formats (skipped)...') 33 | 34 | vfmt = formatList[0] # choose the first format: vfmt.Width, vfmt.Height, vfmt.BPP 35 | print('Selected camera format:', vfmt) 36 | FSDK.SetVideoFormat(camera, vfmt) 37 | 38 | print("Trying to open '%s'... " % camera, end='') 39 | camera = FSDK.OpenVideoCamera(camera) 40 | print("OK", camera.handle) 41 | 42 | try: 43 | fsdkTracker = FSDK.Tracker.FromFile(trackerMemoryFile) 44 | except: 45 | fsdkTracker = FSDK.Tracker() # creating a FSDK Tracker 46 | 47 | fsdkTracker.SetParameters( 48 | RecognizeFaces=True, DetectFacialFeatures=True, 49 | HandleArbitraryRotations=True, DetermineFaceRotationAngle=False, 50 | InternalResizeWidth=256, FaceDetectionThreshold=5 51 | ) 52 | 53 | need_to_exit = False 54 | 55 | def WndProc(hWnd, message, wParam, lParam): 56 | global capturedFace 57 | if message == win.WM_CTLCOLOREDIT: 58 | fsdkTracker.SetName(capturedFace, win.GetWindowText(inpBox)) 59 | if message == win.WM_DESTROY: 60 | global need_to_exit 61 | need_to_exit = True 62 | else: 63 | if message == win.WM_MOUSEMOVE: 64 | updateActiveFace() 65 | return 1 66 | if message == win.WM_LBUTTONDOWN: 67 | if activeFace and capturedFace != activeFace: 68 | capturedFace = activeFace 69 | win.SetWindowText(inpBox, fsdkTracker.GetName(capturedFace)) 70 | win.ShowWindow(inpBox, win.SW_SHOW) 71 | win.SetFocus(inpBox) 72 | else: 73 | capturedFace = None 74 | win.ShowWindow(inpBox, win.SW_HIDE) 75 | return 1 76 | return win.DefWindowProc(hWnd, message, win.WPARAM(wParam), win.LPARAM(lParam)) 77 | 78 | wcex = win.WNDCLASSEX(cbSize = ctypes.sizeof(win.WNDCLASSEX), style = 0, lpfnWndProc = win.WNDPROC(WndProc), 79 | cbClsExtra = 0, cbWndExtra = 0, hInstance = 0, hIcon = 0, hCursor = win.LoadCursor(0, win.IDC_ARROW), hbrBackground = 0, 80 | lpszMenuName = 0, lpszClassName = win.L("My Window Class"), hIconSm = 0) 81 | win.RegisterClassEx(wcex) 82 | 83 | max_width = 800 84 | max_height = 800 85 | window_width = min(vfmt.Width, max_width) 86 | window_height = min(vfmt.Height, max_height) 87 | 88 | hwnd = win.CreateWindowEx(win.WS_EX_CLIENTEDGE, win.L("My Window Class"), win.L("Live Recognition"), win.WS_SYSMENU | win.WS_CAPTION | win.WS_CLIPCHILDREN, 89 | 100, 100, window_width, window_height, *[0]*4) 90 | win.ShowWindow(hwnd, win.SW_SHOW) 91 | 92 | inpBox = win.CreateWindow(win.L("EDIT"), win.L(""), win.SS_CENTER | win.WS_CHILD, 0, 0, 0, 0, hwnd, 0, 0, 0) 93 | myFont = win.CreateFont(30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, win.L("Microsoft Sans Serif")) 94 | win.SendMessage(inpBox, win.WM_SETFONT, myFont, True) 95 | win.SetWindowPos(inpBox, 0, 0, 0, window_width, 80, win.SWP_NOZORDER) 96 | win.UpdateWindow(hwnd) 97 | 98 | def dot_center(dots): # calc geometric center of dots 99 | return sum(p.x for p in dots)/len(dots), sum(p.y for p in dots)/len(dots) 100 | 101 | class LowPassFilter: # low pass filter to stabilize frame size 102 | def __init__(self, a = 0.35): self.a, self.y = a, None 103 | def __call__(self, x): self.y = self.a * x + (1-self.a)*(self.y or x); return self.y 104 | 105 | class FaceLocator: 106 | def __init__(self, fid): 107 | self.lpf = None 108 | self.center = self.angle = self.frame = None 109 | self.fid = fid 110 | def isIntersect(self, state): 111 | (x1,y1,x2,y2), (xx1,yy1,xx2,yy2) = self.frame, state.frame 112 | return not(x1 >= xx2 or x2 < xx1 or y1 >= yy2 or y2 < yy1) 113 | def isActive(self): return self.lpf is not None 114 | def is_inside(self, x, y): 115 | x -= self.center[0]; y -= self.center[1] 116 | a = self.angle * math.pi / 180 117 | x, y = x*math.cos(a) + y*math.sin(a), x*math.sin(a) - y*math.cos(a) 118 | return (x/self.frame[0])**2 + (y/self.frame[1])**2 <= 1 119 | def draw_shape(self, surf): 120 | container = surf.beginContainer() 121 | surf.translateTransform(*self.center).rotateTransform(self.angle).ellipse(facePen, *self.frame) # draw frame 122 | if activeFace == self.fid: 123 | surf.ellipse(faceActivePen, *self.frame) # draw active frame 124 | if capturedFace == self.fid: 125 | surf.ellipse(faceCapturedPen, *self.frame) # draw captured frame 126 | surf.endContainer(container) 127 | 128 | def draw(self, surf, path, face_id=None): 129 | if face_id is not None: 130 | ff = fsdkTracker.GetFacialFeatures(0, face_id) 131 | if self.lpf is None: self.lpf = LowPassFilter() 132 | xl, yl = dot_center([ff[k] for k in FSDK.FSDKP_LEFT_EYE_SET]) 133 | xr, yr = dot_center([ff[k] for k in FSDK.FSDKP_RIGHT_EYE_SET]) 134 | w = self.lpf((xr - xl)*2.8) 135 | h = w*1.4 136 | self.center = (xr + xl)/2, (yr + yl)/2 + w*0.05 137 | self.angle = math.atan2(yr-yl, xr-xl)*180/math.pi 138 | self.frame = -w/2, -h/2, w/2, h/2 139 | 140 | self.draw_shape(surf) 141 | 142 | name = fsdkTracker.GetName(self.fid) 143 | surf.drawString(name, font, self.center[0]-w/2+2, self.center[1]-h/2+2, text_shadow) 144 | surf.drawString(name, font, self.center[0]-w/2, self.center[1]-h/2, text_color) 145 | else: 146 | if self.lpf is not None: self.lpf, self.countdown = None, 35 147 | self.countdown -= 1 148 | if self.countdown <= 8: 149 | self.frame = [v * 0.95 for v in self.frame] 150 | else: 151 | self.draw_shape(surf) 152 | name='Unknown User!' 153 | 154 | path.ellipse(*self.frame) # frame background 155 | return self.lpf or self.countdown > 0 156 | 157 | activeFace = capturedFace = None 158 | def updateActiveFace(): 159 | global activeFace 160 | p = win.ScreenToClient(hwnd, win.GetCursorPos() ) 161 | for fid, tr in trackers.items(): 162 | if tr.is_inside(p.x, p.y): 163 | activeFace = fid 164 | break 165 | else: activeFace = None 166 | 167 | gdiplus = win.GDIPlus() # initialize GDI+ 168 | graphics = win.Graphics(hwnd=hwnd) 169 | backsurf = win.Bitmap.FromGraphics(window_width, window_height, graphics) 170 | surfGr = win.Graphics(bmp=backsurf).setSmoothing(True) # graphics object for back surface with antialiasing 171 | facePen, featurePen, brush = win.Pen(0x60ffffff, 5), win.Pen(0xa060ff60, 1.8), win.Brush(0x28ffffff) 172 | faceActivePen, faceCapturedPen = win.Pen(0xFF00ff00, 2), win.Pen(0xFFff0000, 3) 173 | font = win.Font(win.FontFamily("Tahoma"), FONT_SIZE) 174 | text_color, text_shadow = win.Brush(0xffffffff), win.Brush(0xff808080) 175 | 176 | trackers = {} 177 | while 1: 178 | img = camera.GrabFrame() 179 | surfGr.resetClip().drawImage(win.Bitmap.FromHBITMAP(img.GetHBitmap())) # fill backsurface with image 180 | 181 | faces = frozenset(fsdkTracker.FeedFrame(0, img)) # recognize all faces in the image 182 | for face_id in faces.difference(trackers): trackers[face_id] = FaceLocator(face_id) # create new trackers 183 | 184 | missed, gpath = [], win.GraphicsPath() 185 | for face_id, tracker in trackers.items(): # iterate over current trackers 186 | if face_id in faces: tracker.draw(surfGr, gpath, face_id) #fsdkTracker.GetFacialFeatures(face_id)) # draw existing tracker 187 | else: missed.append(face_id) 188 | for mt in missed: # find and remove trackers that are not active anymore 189 | st = trackers[mt] 190 | if any(st.isIntersect(trackers[tr]) for tr in faces) or not st.draw(surfGr, gpath): del trackers[mt] 191 | 192 | if capturedFace not in trackers: 193 | capturedFace = None 194 | win.ShowWindow(inpBox, win.SW_HIDE) 195 | updateActiveFace() 196 | 197 | graphics.drawImage(backsurf, 0, 0) # show backsurface 198 | 199 | msg = win.MSG() 200 | if win.PeekMessage(win.byref(msg), 0, 0, 0, win.PM_REMOVE): 201 | win.TranslateMessage(win.byref(msg)) 202 | win.DispatchMessage(win.byref(msg)) 203 | if msg.message == win.WM_KEYDOWN and msg.wParam == win.VK_ESCAPE or need_to_exit: break 204 | 205 | print("Please wait while saving Tracker memory... ", end='', flush=True) 206 | fsdkTracker.SaveToFile(trackerMemoryFile) 207 | win.ShowWindow(hwnd, win.SW_HIDE) 208 | 209 | img.Free() 210 | fsdkTracker.Free() 211 | camera.Close() 212 | 213 | FSDK.FinalizeCapturing() 214 | 215 | FSDK.Finalize() 216 | -------------------------------------------------------------------------------- /LiveRecognition1.py: -------------------------------------------------------------------------------- 1 | #from __future__ import print_function 2 | import sys, fsdk, math, ctypes, time 3 | from fsdk import FSDK 4 | import mysql.connector 5 | import datetime 6 | import time 7 | 8 | 9 | 10 | #from __future__ import print_function 11 | import sys, fsdk, math, ctypes, time 12 | from fsdk import FSDK 13 | import mysql.connector 14 | import datetime 15 | import time 16 | from PIL import Image 17 | import PIL 18 | 19 | 20 | 21 | 22 | license_key = "fVrFCzYC5wOtEVspKM/zfLWVcSIZA4RNqx74s+QngdvRiCC7z7MHlSf2w3+OUyAZkTFeD4kSpfVPcRVIqAKWUZzJG975b/P4HNNzpl11edXGIyGrTO/DImoZksDSRs6wktvgr8lnNCB5IukIPV5j/jBKlgL5aqiwSfyCR8UdC9s=" 23 | 24 | if not fsdk.windows: 25 | print('The program is for Microsoft Windows.'); exit(1) 26 | import win 27 | 28 | trackerMemoryFile = "tracker70.dat" 29 | 30 | FONT_SIZE = 30 31 | 32 | print("Initializing FSDK... ", end='') 33 | FSDK.ActivateLibrary(license_key); 34 | FSDK.Initialize() 35 | print("OK\nLicense info:", FSDK.GetLicenseInfo()) 36 | 37 | FSDK.InitializeCapturing() 38 | print('Looking for video cameras... ', end = '') 39 | camList = FSDK.ListCameraNames() 40 | 41 | if not camList: print("Please attach a camera."); 42 | print(camList[0]) # camList[0].devicePath 43 | 44 | camera = camList[0] # choose the first camera (0) 45 | print("using '%s'" % camera) 46 | formatList = FSDK.ListVideoFormats(camera) 47 | #print(*zip(range(len(formatList)), formatList), sep='\n') 48 | print(*formatList[0:5], sep='\n') 49 | if len(formatList)>5: print('...', len(formatList)-5, 'more formats (skipped)...') 50 | 51 | vfmt = formatList[0] # choose the first format: vfmt.Width, vfmt.Height, vfmt.BPP 52 | print('Selected camera format:', vfmt) 53 | FSDK.SetVideoFormat(camera, vfmt) 54 | 55 | print("Trying to open '%s'... " % camera, end = '') 56 | camera = FSDK.OpenVideoCamera(camera) 57 | print("OK", camera.handle) 58 | 59 | try: 60 | fsdkTracker = FSDK.Tracker.FromFile(trackerMemoryFile) 61 | except: 62 | fsdkTracker = FSDK.Tracker() # creating a FSDK Tracker 63 | 64 | fsdkTracker.SetParameters( # set realtime face detection parameters 65 | RecognizeFaces=True, DetectFacialFeatures=True, 66 | HandleArbitraryRotations=True, DetermineFaceRotationAngle=False, 67 | InternalResizeWidth=256, FaceDetectionThreshold=5 68 | ) 69 | 70 | need_to_exit = False 71 | 72 | 73 | def WndProc(hWnd, message, wParam, lParam): 74 | global capturedFace 75 | if message == win.WM_CTLCOLOREDIT: 76 | fsdkTracker.SetName(capturedFace, win.GetWindowText(inpBox)) 77 | if message == win.WM_DESTROY: 78 | global need_to_exit 79 | need_to_exit = True 80 | else: 81 | if message == win.WM_MOUSEMOVE: 82 | updateActiveFace() 83 | return 1 84 | if message == win.WM_LBUTTONDOWN: 85 | if activeFace and capturedFace != activeFace: 86 | capturedFace = activeFace 87 | win.SetWindowText(inpBox, fsdkTracker.GetName(capturedFace)) 88 | win.ShowWindow(inpBox, win.SW_SHOW) 89 | win.SetFocus(inpBox) 90 | else: 91 | capturedFace = None 92 | win.ShowWindow(inpBox, win.SW_HIDE) 93 | return 1 94 | return win.DefWindowProc(hWnd, message, win.WPARAM(wParam), win.LPARAM(lParam)) 95 | 96 | wcex = win.WNDCLASSEX(cbSize = ctypes.sizeof(win.WNDCLASSEX), style = 0, lpfnWndProc = win.WNDPROC(WndProc), 97 | cbClsExtra = 0, cbWndExtra = 0, hInstance = 0, hIcon = 0, hCursor = win.LoadCursor(0, win.IDC_ARROW), hbrBackground = 0, 98 | lpszMenuName = 0, lpszClassName = win.L("My Window Class"), hIconSm = 0) 99 | win.RegisterClassEx(wcex) 100 | 101 | hwnd = win.CreateWindowEx(win.WS_EX_CLIENTEDGE, win.L("My Window Class"), win.L("Live Recognition"), win.WS_SYSMENU | win.WS_CAPTION | win.WS_CLIPCHILDREN, 102 | 50, 50, vfmt.Width, vfmt.Height, *[0]*4) 103 | win.ShowWindow(hwnd, win.SW_SHOW) 104 | 105 | # textBox = win.CreateWindow(win.L("STATIC"), win.L("Click face to name it"), win.SS_CENTER | win.WS_CHILD, 0, 0, 0, 0, hwnd, 0, 0, 0) 106 | # myFont = win.CreateFont(30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, win.L("Microsoft Sans Serif")) 107 | # win.SendMessage(textBox, win.WM_SETFONT, myFont, True); 108 | # win.SetWindowPos(textBox, 0, 0, vfmt.Height, vfmt.Width, 80, win.SWP_NOZORDER) 109 | # win.ShowWindow(textBox, win.SW_SHOW) 110 | 111 | inpBox = win.CreateWindow(win.L("EDIT"), win.L(""), win.SS_CENTER | win.WS_CHILD, 0, 0, 0, 0, hwnd, 0, 0, 0) 112 | myFont = win.CreateFont(30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, win.L("Microsoft Sans Serif")) 113 | win.SendMessage(inpBox, win.WM_SETFONT, myFont, True); 114 | win.SetWindowPos(inpBox, 0, 0, vfmt.Height-80, vfmt.Width, 80, win.SWP_NOZORDER) 115 | win.UpdateWindow(hwnd) 116 | 117 | def dot_center(dots): # calc geometric center of dots 118 | return sum(p.x for p in dots)/len(dots), sum(p.y for p in dots)/len(dots) 119 | 120 | 121 | 122 | class LowPassFilter: # low pass filter to stabilize frame size 123 | def __init__(self, a = 0.35): self.a, self.y = a, None 124 | def __call__(self, x): self.y = self.a * x + (1-self.a)*(self.y or x); return self.y 125 | 126 | class FaceLocator: 127 | def __init__(self, fid): 128 | self.lpf = None 129 | self.center = self.angle = self.frame = None 130 | self.fid = fid 131 | def isIntersect(self, state): 132 | (x1,y1,x2,y2), (xx1,yy1,xx2,yy2) = self.frame, state.frame 133 | return not(x1 >= xx2 or x2 < xx1 or y1 >= yy2 or y2 < yy1) 134 | def isActive(self): return self.lpf is not None 135 | def is_inside(self, x, y): 136 | x -= self.center[0]; y -= self.center[1] 137 | a = self.angle * math.pi / 180 138 | x, y = x*math.cos(a) + y*math.sin(a), x*math.sin(a) - y*math.cos(a) 139 | return (x/self.frame[0])**2 + (y/self.frame[1])**2 <= 1 140 | def draw_shape(self, surf): 141 | container = surf.beginContainer() 142 | surf.translateTransform(*self.center).rotateTransform(self.angle).ellipse(facePen, *self.frame) # draw frame 143 | if activeFace == self.fid: 144 | surf.ellipse(faceActivePen, *self.frame) # draw active frame 145 | if capturedFace == self.fid: 146 | surf.ellipse(faceCapturedPen, *self.frame) # draw captured frame 147 | surf.endContainer(container) 148 | 149 | def draw(self, surf, path, face_id=None): 150 | if face_id is not None: 151 | ff = fsdkTracker.GetFacialFeatures(0, face_id) 152 | if self.lpf is None: self.lpf = LowPassFilter() 153 | xl, yl = dot_center([ff[k] for k in FSDK.FSDKP_LEFT_EYE_SET]) 154 | xr, yr = dot_center([ff[k] for k in FSDK.FSDKP_RIGHT_EYE_SET]) 155 | w = self.lpf((xr - xl)*2.8) 156 | h = w*1.4 157 | self.center = (xr + xl)/2, (yr + yl)/2 + w*0.05 158 | self.angle = math.atan2(yr-yl, xr-xl)*180/math.pi 159 | self.frame = -w/2, -h/2, w/2, h/2 160 | 161 | self.draw_shape(surf) 162 | 163 | name = fsdkTracker.GetName(self.fid) 164 | #print(name) 165 | surf.drawString(name, font, self.center[0]-w/2+2, self.center[1]-h/2+2, text_shadow) 166 | surf.drawString(name, font, self.center[0]-w/2, self.center[1]-h/2, text_color) 167 | else: 168 | if self.lpf is not None: self.lpf, self.countdown = None, 35 169 | self.countdown -= 1 170 | if self.countdown <= 8: 171 | self.frame = [v * 0.95 for v in self.frame] 172 | else: 173 | self.draw_shape(surf) 174 | name='Unkown User!'; 175 | #print(name) 176 | 177 | path.ellipse(*self.frame) # frame background 178 | return self.lpf or self.countdown > 0 179 | 180 | activeFace = capturedFace = None 181 | def updateActiveFace(): 182 | global activeFace 183 | p = win.ScreenToClient(hwnd, win.GetCursorPos() ) 184 | for fid, tr in trackers.items(): 185 | if tr.is_inside(p.x, p.y): 186 | activeFace = fid 187 | break 188 | else: activeFace = None 189 | 190 | gdiplus = win.GDIPlus() # initialize GDI+ 191 | graphics = win.Graphics(hwnd=hwnd) 192 | backsurf = win.Bitmap.FromGraphics(vfmt.Width, vfmt.Height, graphics) 193 | surfGr = win.Graphics(bmp=backsurf).setSmoothing(True) # graphics object for back surface with antialiasing 194 | facePen, featurePen, brush = win.Pen(0x60ffffff, 5), win.Pen(0xa060ff60, 1.8), win.Brush(0x28ffffff) 195 | faceActivePen, faceCapturedPen = win.Pen(0xFF00ff00, 2), win.Pen(0xFFff0000, 3) 196 | font = win.Font(win.FontFamily("Tahoma"), FONT_SIZE) 197 | text_color, text_shadow = win.Brush(0xffffffff), win.Brush(0xff808080) 198 | 199 | trackers = {} 200 | def att(): 201 | pass 202 | def sendmsg(targetno,message): 203 | import requests 204 | requests.post( 205 | "http://sms.creativepoint.in/api/push.json?apikey=6555c521622c1&route=transsms&sender=FSSMSS&mobileno=" + targetno + "&text=Dear customer your msg is " + message + " Sent By FSMSG FSSMSS") 206 | 207 | 208 | 209 | 210 | sampleNum = 0 211 | while 1: 212 | sampleNum = sampleNum + 1 213 | img = camera.GrabFrame() 214 | surfGr.resetClip().drawImage(win.Bitmap.FromHBITMAP(img.GetHBitmap())) # fill backsurface with image 215 | 216 | faces = frozenset(fsdkTracker.FeedFrame(0, img)) # recognize all faces in the image 217 | for face_id in faces.difference(trackers): trackers[face_id] = FaceLocator(face_id) # create new trackers 218 | 219 | missed, gpath = [], win.GraphicsPath() 220 | for face_id, tracker in trackers.items(): # iterate over current trackers 221 | ss = fsdkTracker.GetName(face_id) 222 | if sampleNum > 50: 223 | ts = time.time() 224 | date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') 225 | timeStamp = datetime.datetime.fromtimestamp(ts).strftime('%H:%M:%S') 226 | conn = mysql.connector.connect(user='root', password='', host='localhost', database='1faceiotdb') 227 | cursor = conn.cursor() 228 | cursor.execute("select * from regtb where UserName='" + str(ss) + "' ") 229 | data = cursor.fetchone() 230 | if data is None: 231 | print("No Face Info Found") 232 | 233 | # from playsound import playsound 234 | 235 | sendmsg("9655034039","Face Decect!") 236 | 237 | import winsound 238 | 239 | filename = 'alert.wav' 240 | winsound.PlaySound(filename, winsound.SND_FILENAME) 241 | 242 | outFileName = 'static/out.jpg' 243 | 244 | bmp = win.Bitmap.FromHBITMAP(img.GetHBitmap()) 245 | 246 | saimg = FSDK.Image(bmp.GetHBITMAP()) 247 | saimg.SaveToFile(outFileName, quality=85) 248 | 249 | import smtplib 250 | from email.mime.multipart import MIMEMultipart 251 | from email.mime.text import MIMEText 252 | from email.mime.base import MIMEBase 253 | from email import encoders 254 | 255 | fromaddr = "projectmailm@gmail.com" 256 | toaddr = "devadharshiniakshaya@gmail.com" 257 | 258 | # instance of MIMEMultipart 259 | msg = MIMEMultipart() 260 | 261 | # storing the senders email address 262 | msg['From'] = fromaddr 263 | 264 | # storing the receivers email address 265 | msg['To'] = toaddr 266 | 267 | # storing the subject 268 | msg['Subject'] = "Face Detection" 269 | 270 | # string to store the body of the mail 271 | body = "Hai" 272 | 273 | # attach the body with the msg instance 274 | msg.attach(MIMEText(body, 'plain')) 275 | 276 | # open the file to be sent 277 | filename = "out.png" 278 | attachment = open("static/out.jpg", "rb") 279 | 280 | # instance of MIMEBase and named as p 281 | p = MIMEBase('application', 'octet-stream') 282 | 283 | # To change the payload into encoded form 284 | p.set_payload((attachment).read()) 285 | 286 | # encode into base64 287 | encoders.encode_base64(p) 288 | 289 | p.add_header('Content-Disposition', "attachment; filename= %s" % filename) 290 | 291 | # attach the instance 'p' to instance 'msg' 292 | msg.attach(p) 293 | 294 | # creates SMTP session 295 | s = smtplib.SMTP('smtp.gmail.com', 587) 296 | 297 | # start TLS for security 298 | s.starttls() 299 | 300 | # Authentication 301 | s.login(fromaddr, "qmgn xecl bkqv musr") 302 | 303 | # Converts the Multipart msg into a string 304 | text = msg.as_string() 305 | 306 | # sending the mail 307 | s.sendmail(fromaddr, toaddr, text) 308 | 309 | # terminating the session 310 | s.quit() 311 | else: 312 | conn = mysql.connector.connect(user='root', password='', host='localhost', database='1faceiotdb') 313 | cursor = conn.cursor() 314 | cursor.execute("select * from entrytb where Date='" + str(date) + "' and UserName='" + str(ss) + "'") 315 | data = cursor.fetchone() 316 | if data is None: 317 | conn = mysql.connector.connect(user='root', password='', host='localhost', 318 | database='1faceiotdb') 319 | cursor = conn.cursor() 320 | cursor.execute( 321 | "insert into entrytb values('','" + ss + "','" + str(date) + "','" + str( 322 | timeStamp) + "','1')") 323 | conn.commit() 324 | conn.close() 325 | #print("Face Attendance Info Saved") 326 | else: 327 | print("Already Face Attendance Info Saved") 328 | 329 | sendmsg("9655034039","Criminal Face Name" + ss) 330 | 331 | import winsound 332 | 333 | filename = 'alert.wav' 334 | winsound.PlaySound(filename, winsound.SND_FILENAME) 335 | 336 | outFileName = 'static/out.jpg' 337 | 338 | bmp = win.Bitmap.FromHBITMAP(img.GetHBitmap()) 339 | 340 | saimg = FSDK.Image(bmp.GetHBITMAP()) 341 | saimg.SaveToFile(outFileName, quality=85) 342 | 343 | import smtplib 344 | from email.mime.multipart import MIMEMultipart 345 | from email.mime.text import MIMEText 346 | from email.mime.base import MIMEBase 347 | from email import encoders 348 | 349 | fromaddr = "projectmailm@gmail.com" 350 | toaddr = "devadharshiniakshaya@gmail.com" 351 | 352 | # instance of MIMEMultipart 353 | msg = MIMEMultipart() 354 | 355 | # storing the senders email address 356 | msg['From'] = fromaddr 357 | 358 | # storing the receivers email address 359 | msg['To'] = toaddr 360 | 361 | # storing the subject 362 | msg['Subject'] = "Face Detection" 363 | 364 | # string to store the body of the mail 365 | body = "Criminal Face Name" + ss 366 | 367 | # attach the body with the msg instance 368 | msg.attach(MIMEText(body, 'plain')) 369 | 370 | # open the file to be sent 371 | filename = "out.png" 372 | attachment = open("static/out.jpg", "rb") 373 | 374 | # instance of MIMEBase and named as p 375 | p = MIMEBase('application', 'octet-stream') 376 | 377 | # To change the payload into encoded form 378 | p.set_payload((attachment).read()) 379 | 380 | # encode into base64 381 | encoders.encode_base64(p) 382 | 383 | p.add_header('Content-Disposition', "attachment; filename= %s" % filename) 384 | 385 | # attach the instance 'p' to instance 'msg' 386 | msg.attach(p) 387 | 388 | # creates SMTP session 389 | s = smtplib.SMTP('smtp.gmail.com', 587) 390 | 391 | # start TLS for security 392 | s.starttls() 393 | 394 | # Authentication 395 | s.login(fromaddr, "qmgn xecl bkqv musr") 396 | 397 | # Converts the Multipart msg into a string 398 | text = msg.as_string() 399 | 400 | # sending the mail 401 | s.sendmail(fromaddr, toaddr, text) 402 | 403 | # terminating the session 404 | s.quit() 405 | 406 | 407 | 408 | 409 | 410 | 411 | if face_id in faces: tracker.draw(surfGr, gpath, face_id) #fsdkTracker.GetFacialFeatures(face_id)) # draw existing tracker 412 | else: missed.append(face_id) 413 | for mt in missed: # find and remove trackers that are not active anymore 414 | st = trackers[mt] 415 | if any(st.isIntersect(trackers[tr]) for tr in faces) or not st.draw(surfGr, gpath): del trackers[mt] 416 | 417 | if capturedFace not in trackers: 418 | capturedFace = None 419 | win.ShowWindow(inpBox, win.SW_HIDE) 420 | updateActiveFace() 421 | 422 | # surfGr.clipPath(gpath, win.CombineModeExclude).fillRect(brush, 0, 0, vfmt.Width, vfmt.Height) # clip frames 423 | graphics.drawImage(backsurf, 0, 0) # show backsurface 424 | 425 | #Close 426 | if sampleNum > 50: 427 | sampleNum=0 428 | break 429 | 430 | 431 | 432 | msg = win.MSG() 433 | if win.PeekMessage(win.byref(msg), 0, 0, 0, win.PM_REMOVE): 434 | #win.TranslateMessage(win.byref(msg)) 435 | #win.DispatchMessage(win.byref(msg)) 436 | if msg.message == win.WM_KEYDOWN and msg.wParam == win.VK_ESCAPE or need_to_exit: break 437 | 438 | print("Please wait while saving Tracker memory... ", end='', flush=True) 439 | fsdkTracker.SaveToFile(trackerMemoryFile) 440 | win.ShowWindow(hwnd, win.SW_HIDE) 441 | 442 | img.Free() 443 | fsdkTracker.Free() 444 | camera.Close() 445 | 446 | FSDK.FinalizeCapturing() 447 | 448 | FSDK.Finalize() 449 | 450 | 451 | 452 | -------------------------------------------------------------------------------- /Main.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import os 3 | from tkinter import filedialog 4 | from pymsgbox import * 5 | import mysql.connector 6 | from tkinter import messagebox 7 | import urllib 8 | import urllib.request 9 | import urllib.parse 10 | import tkinter as tk 11 | from tkinter import ttk 12 | 13 | os.environ['OPENCV_VIDEOIO_PRIORITY_MSMF'] = '0' 14 | 15 | 16 | def endprogram(): 17 | print("\nProgram terminated!") 18 | sys.exit() 19 | 20 | 21 | def training(): 22 | global training_screen 23 | training_screen = Toplevel(main_screen) 24 | training_screen.title("Training") 25 | # login_screen.geometry("400x300") 26 | training_screen.geometry("600x450+650+150") 27 | training_screen.minsize(120, 1) 28 | training_screen.maxsize(1604, 881) 29 | training_screen.resizable(1, 1) 30 | # login_screen.title("New Toplevel") 31 | 32 | Label(training_screen, text='''Upload Image ''', background="#d9d9d9", disabledforeground="#a3a3a3", 33 | foreground="#000000", bg="turquoise", width="300", height="2", font=("Calibri", 16)).pack() 34 | Label(training_screen, text="").pack() 35 | Label(training_screen, text="").pack() 36 | Label(training_screen, text="").pack() 37 | Button(training_screen, text='''Upload Image''', font=( 38 | 'Verdana', 15), height="2", width="30").pack() 39 | 40 | 41 | # Designing popup for user not found 42 | def testing(): 43 | global testing_screen 44 | testing_screen = Toplevel(main_screen) 45 | testing_screen.title("Testing") 46 | # login_screen.geometry("400x300") 47 | testing_screen.geometry("600x450+650+150") 48 | testing_screen.minsize(120, 1) 49 | testing_screen.maxsize(1604, 881) 50 | testing_screen.resizable(1, 1) 51 | # login_screen.title("New Toplevel") 52 | 53 | Label(testing_screen, text='''Upload Image''', background="#d9d9d9", disabledforeground="#a3a3a3", 54 | foreground="#000000", bg="turquoise", width="300", height="2", font=("Calibri", 16)).pack() 55 | Label(testing_screen, text="").pack() 56 | Label(testing_screen, text="").pack() 57 | Label(testing_screen, text="").pack() 58 | Button(testing_screen, text='''Upload Image''', font=( 59 | 'Verdana', 15), height="2", width="30").pack() 60 | 61 | 62 | # Implementing event on login button 63 | 64 | def login_verify(): 65 | username1 = username_verify.get() 66 | password1 = password_verify.get() 67 | username_login_entry.delete(0, END) 68 | password_login_entry.delete(0, END) 69 | 70 | list_of_files = os.listdir() 71 | if username1 in list_of_files: 72 | file1 = open(username1, "r") 73 | verify = file1.read().splitlines() 74 | if password1 in verify: 75 | Alogin_sucess() 76 | 77 | else: 78 | password_not_recognised() 79 | 80 | else: 81 | user_not_found() 82 | 83 | 84 | # Designing popup for login success 85 | 86 | def Alogin_sucess(): 87 | global login_success_screen 88 | login_success_screen = Toplevel(login_screen) 89 | login_success_screen.title("Success") 90 | login_success_screen.geometry("150x100") 91 | Label(login_success_screen, text="Login Success").pack() 92 | Button(login_success_screen, text="OK", command=register).pack() 93 | 94 | 95 | def password_not_recognised(): 96 | global password_not_recog_screen 97 | password_not_recog_screen = Toplevel(login_screen) 98 | password_not_recog_screen.title("Success") 99 | password_not_recog_screen.geometry("150x100") 100 | Label(password_not_recog_screen, text="Invalid Password ").pack() 101 | Button(password_not_recog_screen, text="OK").pack() 102 | 103 | 104 | # Designing popup for user not found 105 | def register_sucess(): 106 | global register_success_screen 107 | register_success_screen = Toplevel(register_screen) 108 | register_success_screen.title("Success") 109 | register_success_screen.geometry("150x100") 110 | Label(register_success_screen, text="Register Success").pack() 111 | Button(register_success_screen, text="OK", command=delete_register_success).pack() 112 | 113 | 114 | def delete_register_success(): 115 | import LiveRecognition as liv 116 | 117 | liv.att() 118 | del sys.modules["LiveRecognition"] 119 | register_success_screen.destroy() 120 | register_screen.destroy() 121 | 122 | 123 | def viewrecord(): 124 | import grid as grid 125 | 126 | grid() 127 | del sys.modules["grid"] 128 | register_success_screen.destroy() 129 | register_screen.destroy() 130 | 131 | 132 | def viewrentry(): 133 | import entry as entry 134 | 135 | entry() 136 | del sys.modules["entry"] 137 | register_success_screen.destroy() 138 | register_screen.destroy() 139 | 140 | 141 | def user_not_found(): 142 | global user_not_found_screen 143 | user_not_found_screen = Toplevel(login_screen) 144 | user_not_found_screen.title("Success") 145 | user_not_found_screen.geometry("150x100") 146 | Label(user_not_found_screen, text="User Not Found").pack() 147 | Button(user_not_found_screen, text="OK").pack() 148 | 149 | 150 | # Deleting popups 151 | def userlog(): 152 | global login_screen 153 | login_screen = Toplevel(main_screen) 154 | login_screen.title("Login") 155 | login_screen.geometry("600x280") 156 | login_screen.title("Login Form") 157 | global username_verify 158 | global password_verify 159 | 160 | username_verify = StringVar() 161 | password_verify = StringVar() 162 | 163 | global username_login_entry 164 | global password_login_entry 165 | label_0 = Label(login_screen, text="Login form", width=20, font=("bold", 20)) 166 | label_0.place(x=90, y=53) 167 | 168 | label_1 = Label(login_screen, text="UserName", width=20, font=("bold", 10)) 169 | label_1.place(x=80, y=130) 170 | username_login_entry = Entry(login_screen, textvariable=username_verify) 171 | username_login_entry.place(x=240, y=130) 172 | 173 | label_2 = Label(login_screen, text="Password", width=20, font=("bold", 10)) 174 | label_2.place(x=68, y=180) 175 | password_login_entry = Entry(login_screen, textvariable=password_verify, show='*') 176 | password_login_entry.place(x=240, y=180) 177 | # Button(login_screen,text="Login", command=userlogin, font=('helvetica', 12, 'bold')).pack(side=BOTTOM) 178 | 179 | bluebutton = Button(login_screen, text="Login", fg="blue", font=('helvetica', 12), command=userlogin) 180 | bluebutton.place(x=220, y=210) 181 | bluebutton1 = Button(login_screen, text="Reset", fg="blue", font=('helvetica', 12), command=userlog) 182 | bluebutton1.place(x=300, y=210) 183 | 184 | bluebutton2 = Button(login_screen, text="New User Register", fg="blue", font=('helvetica', 12), command=register) 185 | bluebutton2.place(x=300, y=250) 186 | 187 | 188 | def Adminlog(): 189 | global login_screen 190 | login_screen = Toplevel(main_screen) 191 | login_screen.title("Login") 192 | login_screen.geometry("600x280") 193 | login_screen.title("Login Form") 194 | global username_verify 195 | global password_verify 196 | 197 | username_verify = StringVar() 198 | password_verify = StringVar() 199 | 200 | global username_login_entry 201 | global password_login_entry 202 | label_0 = Label(login_screen, text="Login form", width=20, font=("bold", 20)) 203 | label_0.place(x=90, y=53) 204 | 205 | label_1 = Label(login_screen, text="UserName", width=20, font=("bold", 10)) 206 | label_1.place(x=80, y=130) 207 | username_login_entry = Entry(login_screen, textvariable=username_verify) 208 | username_login_entry.place(x=240, y=130) 209 | 210 | label_2 = Label(login_screen, text="Password", width=20, font=("bold", 10)) 211 | label_2.place(x=68, y=180) 212 | password_login_entry = Entry(login_screen, textvariable=password_verify, show='*') 213 | password_login_entry.place(x=240, y=180) 214 | # Button(login_screen,text="Login", command=userlogin, font=('helvetica', 12, 'bold')).pack(side=BOTTOM) 215 | 216 | bluebutton = Button(login_screen, text="Login", fg="blue", font=('helvetica', 12), command=adminlogin) 217 | bluebutton.place(x=220, y=210) 218 | bluebutton1 = Button(login_screen, text="Reset", fg="blue", font=('helvetica', 12), command=Adminlog) 219 | bluebutton1.place(x=300, y=210) 220 | 221 | 222 | def adminlogin(): 223 | username1 = username_verify.get() 224 | password1 = password_verify.get() 225 | print(username1) 226 | print(password1) 227 | conn = mysql.connector.connect(user='root', password='', host='localhost', database='1faceiotdb') 228 | cursor = conn.cursor() 229 | cursor.execute("SELECT * from admintb where uname='" + username1 + "' and password='" + password1 + "'") 230 | data = cursor.fetchone() 231 | 232 | if data is None: 233 | print('Username or Password is wrong') 234 | else: 235 | Alogin_sucess() 236 | 237 | 238 | def userlogin(): 239 | username1 = username_verify.get() 240 | password1 = password_verify.get() 241 | print(username1) 242 | print(password1) 243 | conn = mysql.connector.connect(user='root', password='', host='localhost', database='1faceiotdb') 244 | cursor = conn.cursor() 245 | cursor.execute("SELECT * from register where uname='" + username1 + "' and password='" + password1 + "'") 246 | data = cursor.fetchone() 247 | 248 | if data is None: 249 | print('Username or Password is wrong') 250 | else: 251 | Alogin_sucess() 252 | 253 | 254 | def register(): 255 | global register_screen 256 | register_screen = Toplevel(main_screen) 257 | register_screen.title("New User") 258 | register_screen.geometry("700x600") 259 | register_screen.title("New UserRegister Form") 260 | global name 261 | global email 262 | global var 263 | global address 264 | global pnumber 265 | global uname 266 | 267 | name = StringVar() 268 | email = StringVar() 269 | 270 | address = StringVar() 271 | pnumber = StringVar() 272 | uname = StringVar() 273 | 274 | global name1 275 | global email1 276 | global var1 277 | global address1 278 | global pnumber1 279 | global uname1 280 | 281 | label_0 = Label(register_screen, text="Criminal Register form", width=20, font=("bold", 20)) 282 | 283 | label_0.place(x=90, y=60) 284 | label_1 = Label(register_screen, text="FullName", width=20, font=("bold", 10)) 285 | label_1.place(x=80, y=130) 286 | name1 = Entry(register_screen, textvariable=name) 287 | name1.place(x=240, y=130) 288 | label_3 = Label(register_screen, text="Email", width=20, font=("bold", 10)) 289 | label_3.place(x=68, y=230) 290 | email1 = Entry(register_screen, textvariable=email) 291 | email1.place(x=240, y=230) 292 | # this creates 'Label' widget for Gender and uses place() method. 293 | label_4 = Label(register_screen, text="Gender", width=20, font=("bold", 10)) 294 | label_4.place(x=70, y=180) 295 | # the variable 'var' mentioned here holds Integer Value, by deault 0 296 | var = IntVar() 297 | 298 | Radiobutton(register_screen, text="Male", padx=5, variable=var, value=1).place(x=235, y=180) 299 | Radiobutton(register_screen, text="Female", padx=20, variable=var, value=2).place(x=290, y=180) 300 | ##this creates 'Label' widget for country and uses place() method. 301 | label_5 = Label(register_screen, text="Address", width=20, font=("bold", 10)) 302 | label_5.place(x=80, y=280) 303 | address1 = Entry(register_screen, textvariable=address) 304 | address1.place(x=240, y=280) 305 | label_6 = Label(register_screen, text="phoneNumber", width=20, font=("bold", 10)) 306 | label_6.place(x=80, y=330) 307 | pnumber1 = Entry(register_screen, textvariable=pnumber) 308 | pnumber1.place(x=240, y=330) 309 | label_7 = Label(register_screen, text="UserName", width=20, font=("bold", 10)) 310 | label_7.place(x=80, y=380) 311 | uname1 = Entry(register_screen, textvariable=uname) 312 | uname1.place(x=240, y=380) 313 | 314 | Button(register_screen, text='Submit', width=20, bg="black", fg='white', command=userregister).place(x=180, y=480) 315 | Button(register_screen, text='reset', width=20, bg="black", fg='white').place(x=380, y=480) 316 | Button(register_screen, text='ViewRecord', width=20, bg="black", fg='white', command=viewrecord).place(x=580, y=480) 317 | Button(register_screen, text='ViewRecord', width=20, bg="black", fg='white', command=viewrentry).place(x=10, y=20) 318 | 319 | 320 | def userregister(): 321 | name1 = name.get() 322 | gender1 = var.get() 323 | email1 = email.get() 324 | address1 = address.get() 325 | pnumber1 = pnumber.get() 326 | uname1 = uname.get() 327 | 328 | gen = '' 329 | if gender1 == 1: 330 | gen = 'Male' 331 | else: 332 | gen = 'Female' 333 | 334 | conn = mysql.connector.connect(user='root', password='', host='localhost', database='1faceiotdb') 335 | cursor = conn.cursor() 336 | cursor.execute("insert into regtb values('','" + name1 + "','" + str( 337 | gen) + "','" + pnumber1 + "','" + email1 + "','" + address1 + "','" + uname1 + "')") 338 | conn.commit() 339 | conn.close() 340 | register_sucess() 341 | 342 | 343 | def facedet1(): 344 | import LiveRecognition1 as liv 345 | 346 | liv.att() 347 | del sys.modules["LiveRecognition1"] 348 | newmotion() 349 | 350 | 351 | def newmotion(): 352 | import cv2 353 | 354 | cap = cv2.VideoCapture(0) 355 | 356 | # get initial frame 357 | ret, frame1 = cap.read() 358 | gray1 = cv2.cvtColor(frame1, cv2.COLOR_BGR2GRAY) 359 | 360 | # set up parameters for motion detection 361 | motion_threshold = 30 362 | kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3)) 363 | 364 | count = 0 365 | 366 | while True: 367 | # read current frame 368 | ret, frame2 = cap.read() 369 | if not ret: 370 | break 371 | gray2 = cv2.cvtColor(frame2, cv2.COLOR_BGR2GRAY) 372 | 373 | # calculate difference between frames 374 | frame_diff = cv2.absdiff(gray1, gray2) 375 | 376 | # threshold the difference to detect motion 377 | _, thresh = cv2.threshold(frame_diff, motion_threshold, 255, cv2.THRESH_BINARY) 378 | 379 | # apply morphological operations to reduce noise and fill gaps 380 | thresh = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel) 381 | 382 | # find contours of motion 383 | contours, _ = cv2.findContours(thresh, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) 384 | 385 | # draw bounding box around each contour and track motion 386 | for contour in contours: 387 | (x, y, w, h) = cv2.boundingRect(contour) 388 | cv2.rectangle(frame2, (x, y), (x + w, y + h), (0, 255, 0), 2) 389 | count += 1 390 | if count == 400: 391 | count = 0 392 | print('motion') 393 | import winsound 394 | import datetime 395 | import time 396 | ts = time.time() 397 | date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d') 398 | timeStamp = datetime.datetime.fromtimestamp(ts).strftime('%H:%M:%S') 399 | now = time.localtime() 400 | filename = 'alert.wav' 401 | winsound.PlaySound(filename, winsound.SND_FILENAME) 402 | sendmsg("9626746446", "Motion Detected") 403 | 404 | cv2.waitKey(1) 405 | cap.release() 406 | cv2.destroyAllWindows() 407 | 408 | cv2.VideoCapture.release(cap) 409 | test() 410 | 411 | #print(now.tm_hour) 412 | #if now.tm_hour >= 12: 413 | #if now.tm_min > 00: 414 | 415 | 416 | 417 | 418 | # cap.release() 419 | # cv2.destroyAllWindows() 420 | 421 | cv2.imshow("Motion Detection and Tracking", frame2) 422 | if cv2.waitKey(1) == ord('q'): 423 | break 424 | 425 | # update current frame 426 | gray1 = gray2 427 | 428 | cap.release() 429 | cv2.destroyAllWindows() 430 | 431 | 432 | def test(): 433 | import cv2 434 | cv2.waitKey(5) 435 | cv2.destroyAllWindows() 436 | facedet1() 437 | 438 | 439 | def sendmsg(targetno,message): 440 | import requests 441 | requests.post( 442 | "http://sms.creativepoint.in/api/push.json?apikey=6555c521622c1&route=transsms&sender=FSSMSS&mobileno=" + targetno + "&text=Dear customer your msg is " + message + " Sent By FSMSG FSSMSS") 443 | 444 | 445 | 446 | def main_account_screen(): 447 | global main_screen 448 | main_screen = Tk() 449 | width = 600 450 | height = 600 451 | screen_width = main_screen.winfo_screenwidth() 452 | screen_height = main_screen.winfo_screenheight() 453 | x = (screen_width / 2) - (width / 2) 454 | y = (screen_height / 2) - (height / 2) 455 | main_screen.geometry("%dx%d+%d+%d" % (width, height, x, y)) 456 | main_screen.resizable(0, 0) 457 | # main_screen.geometry("300x250") 458 | main_screen.title("Anomaly Detection") 459 | 460 | Label(text="Anomaly Detection", bg="turquoise", width="300", height="5", font=("Calibri", 16)).pack() 461 | 462 | Button(text="Training", font=( 463 | 'Verdana', 15), height="2", width="30", command=Adminlog, highlightcolor="black").pack(side=TOP) 464 | Label(text="").pack() 465 | 466 | Button(text="Testing", font=('Verdana', 15), height="2", width="30", command=newmotion).pack(side=TOP) 467 | 468 | Label(text="").pack() 469 | 470 | main_screen.mainloop() 471 | 472 | 473 | main_account_screen() 474 | --------------------------------------------------------------------------------