Пример #1
0
 def btTakeImage(self):
     student_id = str(self.txt.get()).upper()
     name = str(self.txt2.get())
     if (name.isalpha() or (' ' in name)):
         mycamera = VideoCapture.MyVideoCapture(0)
         if not mycamera.vid.isOpened():
             res = "Unable to open this camera"
             self.message.configure(text=res)
         else:
             sql3 = Sqlite3Brower.Sqlite3(name, student_id)
             if sql3.checkStudentId():
                 res = 'Student ID already exists'
             else:
                 mycamera.getFrame()
                 sql3.insertStudent()
                 res = "Images Taken for ID: " + student_id
                 self.flag = True
             self.message.configure(text=res)
     elif not name.isalpha():
         res = "Please Enter correct information"
         self.message.configure(text=res)
Пример #2
0
    def btTakeAttendance(self):
        mycamera = VideoCapture.MyVideoCapture(0)
        if not mycamera.vid.isOpened():
            res = "Unable to open this camera"
            self.message.configure(text=res)
        else:
            profile = mycamera.reconigizer()
            date = datetime.datetime.fromtimestamp(
                time.time()).strftime('%d-%m-%Y')
            exists = os.path.isfile("Attendance\Attendance_" + date + ".csv")
            col_names = ['ID', 'STID', 'Name', 'Time']
            if exists:
                with open("Attendance\Attendance_" + date + ".csv",
                          'a+') as csvFile1:
                    writer = csv.writer(csvFile1)
                    for student in profile:
                        self.tv.insert('',
                                       0,
                                       text=student[1],
                                       value=(str(student[2]), date,
                                              student[3]))
                        writer.writerow(student)
                csvFile1.close()
            else:
                with open("Attendance\Attendance_" + date + ".csv",
                          'a+') as csvFile1:
                    writer = csv.writer(csvFile1)
                    writer.writerow(col_names)
                    for student in profile:
                        self.tv.insert('',
                                       0,
                                       text=student[1],
                                       value=(str(student[2]), date,
                                              student[3]))
                        writer.writerow(student)
                csvFile1.close()

            res = "Attendance complete"
            self.message.configure(text=res)
Пример #3
0
                    csv_writer.writerow(rowx)
                rowy = [cursorx / 1919, cursory / 1079]
                with open("ytrain2.csv", 'a+', newline='') as write_obj:
                    csv_writer = writer(write_obj)
                    csv_writer.writerow(rowy)
            return [frame, rowx]


def nothing(val):
    pass


# # #
cv2.namedWindow('image')
cv2.createTrackbar('threshold', 'image', 42, 255, nothing)
vs = VideoCapture.MyVideoCapture()
sp = seqpose.SEQP()
et = EyeTracker(vid=vs, seqp=sp)
s = Seq.SEQ()
while True:
    thresh_val = cv2.getTrackbarPos('threshold', 'image')
    et.pupil_thresh = thresh_val
    # print(pyautogui.position())
    save = win32api.GetAsyncKeyState(0x20)
    # start_time = time.time()
    f = et.mainloop(save)
    if len(f) != 0:
        print(np.shape(f[1]))
        p = s.predict(np.array([f[1]]))
        x = p[0][0] * 1919
        y = p[0][1] * 1079
Пример #4
0
import cv2
import numpy as np
import Finder
import VideoCapture
import statistics
import matplotlib.pyplot as plt

finder = Finder.FeatureFinder()
videocap = VideoCapture.MyVideoCapture()
face = cv2.imread("face.jpg")
img = face
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blur = cv2.GaussianBlur(gray, (7, 7), 0)
_, threshold = cv2.threshold(blur, 25, 255, cv2.THRESH_BINARY_INV)

while True:
    ret, frame = videocap.get_frame()
    finder.set_image(frame)
    if len(finder.roi) == 0:
        finder.find_face()
    if len(finder.roi != 0):
        face = finder.roi
        blur = cv2.GaussianBlur(face, (7, 7), 0)
        _, threshold = cv2.threshold(blur, 25, 255, cv2.THRESH_BINARY_INV)
        contours, heirarchy = cv2.findContours(threshold, cv2.RETR_TREE,
                                               cv2.CHAIN_APPROX_SIMPLE)
        for cnt in contours:
            cv2.drawContours(img, [cnt], -1, (0, 0, 255), 1)
            # M = cv2.moments(cnt)
            # cX = int(M["m10"] / M["m00"])
            # cY = int(M["m01"] / M["m00"])