Commit f19cdf94 authored by Jebarsan dias's avatar Jebarsan dias

Upload New File

parent 2cda09da
import cv2
import os
import sys
import numpy as np
from datetime import datetime
from PyQt5 import QtGui, QtCore
from PyQt5.QtWidgets import QDialog, QApplication, QMainWindow, QMessageBox
from PyQt5.uic import loadUi
class USER(QDialog):
def __init__(self):
super(USER, self).__init__()
loadUi("user_info.ui", self)
def get_name_key(self):
name = self.name_label.text()
key = int(self.key_label.text())
return name, key
class AUFR(QMainWindow):
def __init__(self):
super(AUFR, self).__init__()
loadUi("mainwindow.ui", self)
self.face_classifier = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
self.eye_classifier = cv2.CascadeClassifier("haarcascade_eye.xml")
self.smile_classifier = cv2.CascadeClassifier("haarcascade_smile.xml")
self.camera_id = 0 # can also be a url of Video
self.dataset_per_subject = 50
self.ret = False
self.trained_model = 0
self.image = cv2.imread("", 1)
self.modified_image = self.image.copy()
self.draw_text("fyh", 40, 30, 1, (255, 255, 255))
self.display()
# Actions
self.generate_dataset_btn.setCheckable(True)
self.train_model_btn.setCheckable(True)
self.recognize_face_btn.setCheckable(True)
# Menu
self.about_menu = self.menu_bar.addAction("About")
self.help_menu = self.menu_bar.addAction("Help")
self.about_menu.triggered.connect(self.about_info)
self.help_menu.triggered.connect(self.help_info)
# Algorithms
self.algo_radio_group.buttonClicked.connect(self.algorithm_radio_changed)
# Recangle
self.face_rect_radio.setChecked(True)
self.eye_rect_radio.setChecked(False)
self.smile_rect_radio.setChecked(False)
# Events
self.generate_dataset_btn.clicked.connect(self.generate)
self.train_model_btn.clicked.connect(self.train)
self.recognize_face_btn.clicked.connect(self.recognize)
self.save_image_btn.clicked.connect(self.save_image)
self.video_recording_btn.clicked.connect(self.save_video)
# Recognizers
self.update_recognizer()
self.assign_algorithms()
def start_timer(self): # start the timeer for execution.
self.capture = cv2.VideoCapture(self.camera_id)
self.capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 480)
self.capture.set(cv2.CAP_PROP_FRAME_WIDTH, 640)
self.timer = QtCore.QTimer()
if self.generate_dataset_btn.isChecked():
self.timer.timeout.connect(self.save_dataset)
elif self.recognize_face_btn.isChecked():
self.timer.timeout.connect(self.update_image)
self.timer.start(5)
def stop_timer(self): # stop timer or come out of the loop.
self.timer.stop()
self.ret = False
self.capture.release()
def update_image(self): # update canvas every time according to time set in the timer.
if self.recognize_face_btn.isChecked():
self.ret, self.image = self.capture.read()
self.image = cv2.flip(self.image, 1)
faces = self.get_faces()
self.draw_rectangle(faces)
if self.video_recording_btn.isChecked():
self.recording()
self.display()
\ No newline at end of file
Markdown is supported
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