def updateattendances(): if session.get('login'): attendance = Attendance(dsn=app.config['dsn']) student = Student(dsn=app.config['dsn']) teacher_id = session['login'] attendances = attendance.get_all_attendances_for_teacher(teacher_id) ids = [] names = [] surnames = [] dates = [] rows = [] situations = [] for a in attendances: ids.append(a[0]) my_student = student.get_student(a[1]) names.append(my_student[1]) surnames.append(my_student[2]) dates.append(a[3]) rows.append(a[4]) situations.append(a[5]) return render_template('updateattendances.html', zipped=zip(ids, names, surnames, dates, rows, situations)) else: return redirect(url_for('home_page'))
def startNewAttendance(): if request.method == 'POST': attendance = Attendance(attendanceCollection) data = request.get_json() courseCode = data['courseCode'] date = helpers.getDate() attendanceExits = attendance.getAttendance(date, courseCode) attendanceExits = loads(attendanceExits) if (len(attendanceExits) > 0): res = jsonify('Attendace has already been taken for today') return res student = Students(studentCollection) students = student.getStudentsForParticleCourse(courseCode) stdAttendance = loads(students) for student in stdAttendance: student['present'] = False classAttendance = {'allStudents': stdAttendance, 'unknownStudents': []} obj = { 'courseCode': courseCode, 'date': date, 'classAttendance': classAttendance } att = attendance.addNewAttendance(obj) res = jsonify('New Attendance started.') return res
def main(): att = Attendance() while True: result = att.get_attendance() timestamp, count = parse_result(result) append_to_file(OUTPUT_FILE, ','.join([timestamp, count]) + '\n') time.sleep(WAIT_INTERVAL)
def upload(self): # user_name = userName_lineEdit.text() user_name = '*****@*****.**' # password = password_lineEdit.text() password = '******' Attendance.authenticate(user_name, password) Attendance.upload_pending_attendances(db) self.pending_uploaded_label.setText("Missing " + str(Attendance.pending_attendances_to_upload(self.db)) + " student(s) to upload")
def attendancerecord(): if session.get('login'): studentclassroom = Student_Class(dsn=app.config['dsn']) attendance = Attendance(dsn=app.config['dsn']) sinif = session['sinif'] teacher_id = session['login'] ids = [] ids = studentclassroom.get_id_all_students(sinif) stringvalue = attendance.insert_attendance(ids, sinif) return stringvalue else: return redirect(url_for('home_page'))
def getAttendance(): if request.method == 'POST': attendance = Attendance(attendanceCollection) data = request.get_json() courseCode = data['courseCode'] res = attendance.getAttendanceByCourseCode(courseCode) attendanceObj = loads(res) for att in attendanceObj: for student in att['classAttendance']['allStudents']: student.pop('encodings') return dumps(attendanceObj)
def create_widget_components(self): self.camera_timer = QTimer() self.error_message = QErrorMessage() self.spin_box_label = QLabel("Choose a camera index") self.spin_box = QSpinBox() self.scan_button = QPushButton("Scan") self.upload_button = QPushButton("Upload") self.stop_button = QPushButton("Stop") self.stop_button.setEnabled(False) self.userName_label = QLabel("User Name") self.userName_lineEdit = QLineEdit() self.password_label = QLabel("Password") self.password_lineEdit = QLineEdit() self.password_lineEdit.setEchoMode(2) self.pending_uploaded_label = QLabel("Missing " + str(Attendance.pending_attendances_to_upload(self.db)) + " student(s) to upload") self.camera_image = QLabel() camera_size = self.widget_der.minimumSize() self.pix_map = QPixmap(camera_size) self.pix_map.fill(Qt.black) self.camera_image.setPixmap(self.pix_map) self.course_name_label = QLabel("Course Name") self.course_name_lineEdit = QLineEdit() self.classtype_label = QLabel("Class Type") self.classtype_lineEdit = QLineEdit() self.details_Label = QLabel("Details") self.details_textEdit = QTextEdit()
def take_pic(self, collection_name: str): capture = cv2.VideoCapture(0) face_cascade = cv2.CascadeClassifier( 'cascades/data/haarcascade_frontalface_alt2.xml') image_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'devils_eye') while True: ret, image = capture.read() gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) faces = face_cascade.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5) for (x, y, w, h) in faces: roi_gray = gray[y:y + h, x:x + w] roi_color = image[y:y + h, x:x + w] cv2.imwrite(os.path.join(image_dir, 'target.jpeg'), roi_color) cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2) name = Stalker().run_stalker(collection_name, 'target.jpeg') print(name) if name in self.names_list: pass else: self.names_list.append(name) self.time_list.append(st('%H:%M:%S', gt())) cv2.imshow('look_at_me', image) if cv2.waitKey(20) & 0xFF == ord('q'): break cv2.destroyAllWindows() Attendance(self.names_list, self.time_list).take_attendance()
def procces_frame(self): _, image = self.capture.read() if image is None: self.cancel_scan() self.error_message.setWindowTitle("Invalid camera index") self.error_message.showMessage("The camera index you choose is invalid.\nSelect 0 if you dont't have a USB camera connected") self.error_message.show() return self.showImage(image) qrs = Attendance.get_qrcodes(image, self.scanner) students = Attendance.get_student_from_qrcode(qrs, self.attendance_so_far) Attendance.register_attendance(students, self.class_details, self.db) self.attendance_so_far.extend([student['ID'] for student in students])
def getUpdateAttendance(): if request.method == 'POST': attendance = Attendance(attendanceCollection) data = request.get_json() studentId = data['studentId'] courseCode = data['courseCode'] attendanceId = data['attendanceId'] date = helpers.getDate() res = attendance.updateOne(courseCode, attendanceId, studentId, date) resObj = loads(res) for student in resObj[0]['classAttendance']['allStudents']: student.pop('encodings') return dumps(resObj)
def loading_data(): ''' Creates objects from DB and then a list of all users to loop through for login and password validation. ''' Assignments.assignments_list = Assignments.create_objects_list_from_database('assignements') Attendance.attendances_list = Attendance.create_objects_list_from_database('attendance') Submission.create_objects_list_from_database('submission') Student.add_attendance_to_student(Attendance.attendances_list) # add attendance obj to a specific student Student.create_teams_list()
def __init__(self,name, surname, age, gender, pesel, login, password, date_removed=None, status= 'Active',date_when_added = 'None'): '''Method that initialize instance of Student class.''' User.__init__(self,name, surname, age, gender, pesel, login, password, date_removed, status, date_when_added) self.attendances = Attendance() self.ALL_STUDENTS.append(self) self.grades = [] self.submissions = []
def cancel_scan(self): self.stop_button.setEnabled(False) self.scan_button.setEnabled(True) self.camera_timer.stop() self.capture.release() self.capture = None self.scanner = None self.attendance_so_far = [] self.class_details = {} self.pix_map.fill(Qt.black) self.camera_image.setPixmap(self.pix_map) self.pending_uploaded_label.setText("Missing " + str(Attendance.pending_attendances_to_upload(self.db)) + " student(s) to upload")
def updateattendancecontroller(): if session.get('login'): attendance = Attendance(dsn=app.config['dsn']) attendance_id = request.form['attendance'] operation = request.form['updateordelete'] if str(operation) == 'update': new_situation = request.form['attendancecontrol'] my_attendance = attendance.get_attendance(attendance_id) attendance.update_attendance(attendance_id, my_attendance[1], new_situation) return "Guncelleme basarili" else: attendance.delete_attendance(attendance_id) return "Silme basarili" else: return redirect(url_for('home_page'))
def __init__(self, *args, **kwargs): super(MainWindow, self).__init__(*args, **kwargs) self.capture = None self.scanner = None self.attendance_so_far = [] self.class_details = {} self.db = Attendance.get_data_base_connection() self.setWindowTitle("Attendance") self.create_global_widgets() self.create_global_layouts() self.set_layouts_to_global_widgets() self.create_widget_components() self.add_widgets_to_layouts() self.define_signal_handlers()
def consumer_msg(serverlist): consumer = KafkaConsumer('oa_qian', group_id='my-group', bootstrap_servers=[serverlist]) for message in consumer: msg = bytes.decode(message.value) msglist = msg.split(";") username = msglist[0] password = msglist[1] key = msglist[2] type = msglist[3] oa = Attendance(username, password, key) if (type == '1'): result = oa.singin() print result if (result == 'success'): print oa.log_record(username, type) else: result = oa.singout() print result if (result == 'success'): print oa.log_record(username, type)
def consumer_msg(serverlist): consumer = KafkaConsumer('oa_qian', group_id='my-group', bootstrap_servers=[serverlist]) for message in consumer: msg = bytes.decode(message.value) msglist = msg.split(";") username = msglist[0] password = msglist[1] key = msglist[2] type = msglist[3] oa = Attendance(username, password, key) if (type == '1'): result = oa.singin() print result if(result == 'success'): print oa.log_record(username, type) else: result = oa.singout() print result if(result == 'success'): print oa.log_record(username, type)
def findFaces(): if request.method == 'POST': attendance = Attendance(attendanceCollection) data = request.get_json() # img_data = data['image'] courseCode = data['courseCode'] path = f'api/currentFrame/imageFrame' # helpers.base64toImg(img_data, path) helpers.single_frame(path) # print(d) date = helpers.getDate() # Date of today currentClassAttendace = attendance.getAttendance(date, courseCode) currentClassAttendanceObj = loads(currentClassAttendace) markedAttendace = helpers.findFaces(path, currentClassAttendanceObj) attendance.updateStudentAttendance(currentClassAttendanceObj[0]['_id'], markedAttendace) if os.path.exists(f'{path}.jpg'): os.remove(f'{path}.jpg') else: print("The file does not exist") completeAttendace = attendance.getAttendanceById( currentClassAttendanceObj[0]['_id']) completeAttendaceObj = loads(completeAttendace) for student in completeAttendaceObj['classAttendance']['allStudents']: student.pop('encodings') return dumps(completeAttendaceObj)
import eventlet eventlet.monkey_patch() import cv2 from flask import Flask, render_template, redirect, url_for, request, Response, session, json from flask_socketio import SocketIO from attendance import Attendance import redis #initialize flask application app = Flask(__name__) att = Attendance("config_cam_out.json") att.set_dataset("encode/data.npy", "encode/className.txt") #Create object of SocketIO socketio = SocketIO(app, async_mode="eventlet", async_handlers=True, cookie=None, max_http_buffer_size=300) rds = redis.Redis(host='localhost', port=6379, db=0) def get_frame(): try: cap = cv2.VideoCapture(att.cam_source) while True: if int(rds.get("reload")) == 1: att.set_dataset("encode/data.npy", "encode/className.txt") rds.set("reload", 0) #_, frame = camera.read() _, frame = cap.read()
import json from db_interface import Database from attendance import Attendance attendance_system = Attendance(Database("attendance.db")) print("***********Trying get_attendance('EMP01', '2020-04-01')*************") print( json.dumps(attendance_system.get_attendance('EMP01', '2020-04-02'), indent=4)) print("*********************************Done*******************************\n") print("********************Trying get_history('EMP01')*********************") print(json.dumps(attendance_system.get_history('EMP01'), indent=4)) print("*********************************Done*******************************\n")
def set_attendance(): """There we are setting student attendance""" print(Student.get_student_list()) Attendance.set_attendance()
def check_attendance(): """Print students list and particular student attendance""" print(Student.get_student_list()) Attendance.print_attendance_percentage()
import signal import time import RPi.GPIO as GPIO from attendance import Attendance def sigint_handler(self, *args): print("\n[INFO] Recieve SIGINT. Stop notifier.") GPIO.cleanup() exit(0) if __name__ == "__main__": signal.signal(signal.SIGINT, sigint_handler) attendance = Attendance() attendance.mode = attendance.MODE.ATTEND attendance.daemon = True attendance.start() SWITCH_PIN = 2 RED_LED_PIN = 3 GREEN_LED_PIN = 4 GPIO.setmode(GPIO.BCM) GPIO.setup(SWITCH_PIN, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(RED_LED_PIN, GPIO.OUT) GPIO.setup(GREEN_LED_PIN, GPIO.OUT) last_pin_status = 0 while True: pin_status = GPIO.input(SWITCH_PIN)
def create_db(): if session.get('login'): school = School(dsn=app.config['dsn']) school.init_table() #deneme lesson = Lesson(dsn=app.config['dsn']) lesson.init_table() teacher = Teacher(dsn=app.config['dsn']) teacher.init_table() parent = Parent(dsn=app.config['dsn']) parent.init_table() teacher_account = TeacherAccount(dsn=app.config['dsn']) teacher_account.init_table() student = Student(dsn=app.config['dsn']) student.init_table() #student.insert_student("Boran","Sivrikaya","hotmail") #student.delete_student(student.get_student_id("Boran","Sivrikaya")) #student.insert_student("Boran","Sivrikaya","hotmail") #student.update_student(student.get_student_id("Boran","Sivrikaya"),"Hamza","Tuna","gmail") school = School(dsn=app.config['dsn']) school.init_table() #school.insert_school("Makif") #school.delete_school(school.get_school_id("Makif")) #school.insert_school("GOP") #school.update_school(school.get_school_id("GOP"),"IAFL") classroom = Class(dsn=app.config['dsn']) classroom.init_table() #class.insert_class("9A",2013) #class.delete_class(class.get_class_id("9A",2013)) #class.insert_class("10A",2013) #class.update_class(class.get_class_id("10A",2013),"12C",2015) lesson = Lesson(dsn=app.config['dsn']) lesson.init_table() #lesson.insert_lesson("Math") #lesson.delete_lesson(lesson.get_lesson_id("Math")) #lesson.insert_lesson("History") #lesson.update_lesson(lesson.get_lesson_id("History"),"Science") parent = Parent(dsn=app.config['dsn']) parent.init_table() #parent.insert_parent("Zekiye","Sivrikaya") #parent.delete_parent(parent.get_parent_id("Zekiye","Sivrikaya")) #parent.insert_parent("Hamdi","Sivrikaya") #parent.update_parent(parent.get_parent_id("Hamdi","Sivrikaya"),"Ahmet","Yalcin") schedule = Schedule(dsn=app.config['dsn']) schedule.init_table() #schedule.insert_schedule(5,4,6,2013) #schedule.delete_schedule(schedule.get_schedule_id(5,4)) #schedule.insert_schedule(5,4,6,2013) #schedule.update_schedule(schedule.get_schedule_id(5,4),3,4,6,2020) #session = Session(dsn=app.config['dsn']) #session.init_table() #session.insert_session(3,"2-2-1922",3) #session.delete_session(session.get_session_id(3,"2-2-1922",3)) #session.insert_session(3,"2-2-1922",7) #session.update_session(session.get_session_id(3,"2-2-1922",7),4,"8-8-1994",1) attendance = Attendance(dsn=app.config['dsn']) attendance.init_table() #attendance.insert_attendance(2,4,True) #attendance.delete_attendance(attendance.get_attendance_id(2,4)) #attendance.insert_attendance(2,5,True) #attendance.update_attendance(attendance.get_attendance_id(2,5),4,6,False) grade = Grade(dsn=app.config['dsn']) grade.init_table() #grade.insert_grade(3,2,75,"Iyi not") #grade.delete_grade(grade.get_grade_id(3,2)) #grade.insert_grade(3,2,85,"Daha iyi") #grade.update_grade(grade.get_grade_id(3,2),4,4,20,"VF") schoolclass = SchoolClass(dsn=app.config['dsn']) schoolclass.init_table() #schoolclass.insert_school_class(3,8) #schoolclass.delete_school_class(schoolclass.get_school_class_id(3,8)) #schoolclass.insert_school_class(3,8) #schoolclass.update_school_class(schoolclass.get_school_class_id(3,8),5,10) student_class = Student_Class(dsn=app.config['dsn']) student_class.init_table() #student_class.insert_student_class(3,2) #student_class.delete_student_class(student_class.get_student_class_id(3,2)) #student_class.insert_student_class(5,2) #student_class.update_student_class(student_class.get_student_class_id(5,2),7,4) studentparent = StudentParent(dsn=app.config['dsn']) studentparent.init_table() #studentparent.insert_studentparent(2,2) #studentparent.delete_studentparent(studentparent.get_studentparent_id(2,2)) #studentparent.insert_studentparent(2,2) #studentparent.update_studentparent(studentparent.get_studentparent_id(2,2),4,2) studentschool = StudentSchool(dsn=app.config['dsn']) studentschool.init_table() #studentschool.insert_studentschool(2,8) #studentschool.delete_studentschool(studentschool.get_studentschool_id(2,8)) #studentschool.insert_studentschool(4,10) #studentschool.update_studentschool(studentschool.get_studentschool_id(4,10),4,12) teacherschool = TeacherSchool(dsn=app.config['dsn']) teacherschool.init_table() #teacherschool.insert_teacherschool(2,8) #teacherschool.delete_teacherschool(teacherschool.get_teacherschool_id(2,8)) #teacherschool.insert_teacherschool(4,10) #teacherschool.update_teacherschool(teacherschool.get_teacherschool_id(4,10),6,12) return "Database created" else: return redirect(url_for('home_page'))
def attendance_data(self): self.new_window = Toplevel(self.root) self.app = Attendance(self.new_window)
attendance_soup = bs(attendance_html, 'lxml') tables = attendance_soup.find_all('table') for table in tables: table_rows = table.find_all('tr') for i, tr in enumerate(table_rows): # if i == 0: # continue td_rs = tr.find_all('td') # print(td_rs) raw_list = [] # print("New result-set: ") for td in td_rs: raw_list.append(td.text) raw_data = '\n'.join(raw_list) # print(raw_data) Attendance.insert_attendance(raw_data) print("\nFetching scores") driver.get( 'https://auris.ahduni.edu.in/core-emli/code/student_portal/home.php?page=notification/exam_result' ) temp_element = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.CLASS_NAME, 'logo'))) # # time.sleep(10) scores_html = driver.page_source # scores_html = open('test.html') scores_soup = bs(scores_html, 'lxml') tables = scores_soup.find_all('table') # print(type(tables)) newlineRegex = re.compile(r'\s*<br/>\s*')
def attendance_details(self): self.app = Attendance(self.root, self.id)
import eventlet eventlet.monkey_patch() import cv2 from flask import Flask, render_template, redirect, url_for, request, Response, session, json from flask_socketio import SocketIO from attendance import Attendance import redis #initialize flask application app = Flask(__name__) att = Attendance("config_cam_in.json") att.set_dataset("../dataset/encode/data.npy", "../dataset/encode/className.txt") #Create object of SocketIO socketio = SocketIO(app, async_mode="eventlet", async_handlers=True, cookie=None, max_http_buffer_size=300) rds = redis.Redis(host='localhost', port=6379, db=0) def get_frame(): try: cap = cv2.VideoCapture(att.cam_source) while True: if int(rds.get("reload")) == 1: att.set_dataset("../dataset/encode/data.npy", "../dataset/encode/className.txt") rds.set("reload", 0) #_, frame = camera.read()
def handle_menu(user): """ It doesnt return anything, just handle menu for mentor """ list_options = ['Check the list of students', 'Add an assignment', 'Grade an assignment submitted by students', 'Check attendance of students', 'Add a student to a class', 'Remove a student from class', "Edit student's data", 'Show students of specific group', 'Give a card to student', 'Add student to specific group', 'Show full report of students performance between provided dates', 'Add a team'] while True: os.system('clear') Ui.print_message(('\n...:::Logged in as {}:::...\n').format(user)) Ui.print_menu("What you want to do?", list_options, 'Log out') chose_option = Ui.get_inputs(["Please enter a number: "], "") if chose_option[0] == '1': # print list of students MentorMenu.show_students_data() Ui.get_inputs([''], "Click enter to go back") elif chose_option[0] == '2': # add an assignment to assignment list Assignments.add_an_assignment() Common.write_assignment_to_db('database.db', Assignments.assignments_list) elif chose_option[0] == '3': # grade assignments submitted by students Submission.grade_an_submission() Common.write_submission_to_db('database.db', Submission.submission_list) elif chose_option[0] == '4': # check attendance of students Attendance.attendance_mini_menu() Common.write_attendance_to_db('database.db', Attendance.attendances_list) elif chose_option[0] == '5': # add a student to a class Student.add_person(Student.student_list) Common.write_student_to_db('database.db', Student.student_list) elif chose_option[0] == '6': # remove student from class ManagerMenu.show_students() Student.remove_person(Student.student_list) Common.write_student_to_db('database.db', Student.student_list) elif chose_option[0] == '7': # edit students data ManagerMenu.show_students() person = Student.choose_person_to_change_data(Student.student_list) if person: Employee.data_to_change(person) Common.write_student_to_db('database.db', Student.student_list) elif chose_option[0] == '8': # show students of specific group stu_list = Student.student_list Ui.print_student_teams(stu_list) Ui.get_inputs([''], "Click enter to go back") elif chose_option[0] == '9': # give a card to students MentorMenu.show_students_data() person = Student.choose_person_to_change_data(Student.student_list) if person: Student.change_student_card(person) Common.write_student_to_db('database.db', Student.student_list) elif chose_option[0] == '10': # add student to specific team os.system('clear') Student.add_student_to_team() Common.write_student_to_db('database.db', Student.student_list) elif chose_option[0] == '11': # Show full report of students performance between provided dates Student.show_full_report_of_students_performance() elif chose_option[0] == '12': # Add a new team Student.add_team() Common.write_team_to_db('database.db', Student.teams_list) elif chose_option[0] == '0': sys.exit() else: Ui.print_message('There is no such option.')
from attendance import Attendance if __name__ == "__main__": att = Attendance("config_cam_in.json") # att.generate_class(). # f=att.generate_encode() # encode_list = np.load("encode/data.npy") # att.classNames = att.set_classname("encode/className.txt") # print(classNames) # att.encodeListKnown = encode_list att.set_dataset("encode/data.npy", "encode/className.txt") print(att.classNames) att.stream_vdo()
names = p.createPerson() p.addFaces(names) p.trainPerson() f = Face(PERSON_GROUP_ID, face_client) filename = r'C:\Users\Rudrakshya\Desktop\Internship\Attendance.csv' header = ('Names', 'Attendance') data = [('Abhishek', 0), ('Abinash', 0), ('Amar', 0), ('Aparna', 0), ('Bikash', 0), ('Birendra', 0), ('Deepak', 0), ('Donally', 0), ('Ebadat', 0), ('Hafiz', 0), ('Hanu', 0), ('Prakash', 0), ('Priyadarshinee', 0), ('Priyatosh', 0), ('Rudrakshya', 0), ('Sachin', 0), ('Samir', 0), ('Siddharth', 0), ('Subhankar', 0), ('Taquiuddin', 0), ('Uday', 0)] at = Attendance() at.writer(header, data, filename, 'write') key = cv2.waitKey(1) webcam = cv2.VideoCapture(0) sleep(2) print("Camera opening...") print("\nPress S to capture and Q to quit") while True: try: check, frame = webcam.read() # print(check) #prints true as long as the webcam is running # print(frame) #prints matrix values of each framecd cv2.imshow("Capturing", frame)