I am programming a GUI with Face Detection. My problem is that when I want to switch back to the main GUI (after Face Detection started), the program crashes after the GUI is loaded. The error message is: Process finished with exit code -1073740791 (0xC0000409)
After I click the Back button the GUI loads, but then it crashes...
My code for creating the GUIs (virtually Controller):
app = QApplication(sys.argv)
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.mainGUI()
def registerGUI(self):
self.registerui = registerwindow.Ui_RegisterWindow()
self.registerui.setupUi(self)
self.registerui.zurueck.clicked.connect(self.mainGUI)
self.registerui.aufnahmestart.clicked.connect(self.TakePic)
def loginGUI(self):
self.loginui = loginwindow.Ui_LoginWindow()
self.loginui.setupUi(self)
self.loginui.zurueck.clicked.connect(self.mainGUI)
self.loginui.pushButton_2.clicked.connect(self.dF)
def mainGUI(self):
self.mainui = mainwindow.Ui_MainWindow()
self.mainui.setupUi(self)
self.mainui.registrieren.clicked.connect(self.registerGUI)
self.mainui.login.clicked.connect(self.loginGUI)
def TakePic(self):
exec(open("TakePic.py").read(), globals())
def dF(self):
exec(open("Gesichtserkennung.py").read(), globals())
window = MainWindow()
window.show()
sys.exit(app.exec_())
My code for the Face Detecction and embedding it into the GUI
path = "ImagesProject"
images = []
classNames = []
myList = os.listdir(path)
for element in myList:
images.append(cv2.imread(path + "/" + element))
classNames.append(element[:-4])
def findEncodings(images):
encodingList = []
for img in images:
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
imgEncode = face_recognition.face_encodings(img)[0]
encodingList.append(imgEncode)
return encodingList
encodeListKnown = findEncodings(images)
app = QApplication(sys.argv)
class NewLoginWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.newGUI()
def newGUI(self):
self.ui = loginwindow.Ui_LoginWindow()
self.ui.setupUi(self)
self.ui.zurueck.clicked.connect(self.mainGUI)
def mainGUI(self):
self.mainui = mainwindow.Ui_MainWindow()
self.mainui.setupUi(self)
# self.mainui.registrieren.clicked.connect(self.registerGUI)
# self.mainui.login.clicked.connect(self.loginGUI)
print("1")
window = NewLoginWindow()
cap = VideoCapture(cv2.CAP_DSHOW)
def displayFrame():
timer.start(60)
success, frame = cap.read()
frameS = cv2.resize(frame, (0, 0), None, 0.25, 0.25)
frameS = cv2.cvtColor(frameS, cv2.COLOR_BGR2RGB)
CurFrameFaceLocs = face_recognition.face_locations(frameS)
CurFrameFaceLocEncode = face_recognition.face_encodings(frameS, CurFrameFaceLocs)
for encode, loc in zip(CurFrameFaceLocEncode, CurFrameFaceLocs):
matches = face_recognition.compare_faces(encodeListKnown, encode)
faceDis = face_recognition.face_distance(encodeListKnown, encode)
print(matches)
print(faceDis)
matchIndex = np.argmin(faceDis)
print(matchIndex)
if matches[matchIndex]:
name = classNames[matchIndex].upper()
print(name)
y1, x2, y2, x1 = loc
y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.rectangle(frame, (x1, y2), (x2, y2), (0, 255, 0), cv2.FILLED)
cv2.putText(frame, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
image = qimage2ndarray.array2qimage(frame)
window.ui.label_4.setPixmap(QPixmap.fromImage(image))
window.show()
timer = QTimer()
timer.timeout.connect(displayFrame)
timer.start(60)I am programming a GUI with Face Detection. My problem is that when I want to switch back to the main GUI (after Face Detection started), the program crashes after the GUI is loaded. The error message is: `Process finished with exit code -1073740791 (0xC0000409)`
After I click the Back button the GUI loads, but then it crashes...
My code for creating the GUIs (virtually Controller):
app = QApplication(sys.argv)
class MainWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.mainGUI()
def registerGUI(self):
self.registerui = registerwindow.Ui_RegisterWindow()
self.registerui.setupUi(self)
self.registerui.zurueck.clicked.connect(self.mainGUI)
self.registerui.aufnahmestart.clicked.connect(self.TakePic)
def loginGUI(self):
self.loginui = loginwindow.Ui_LoginWindow()
self.loginui.setupUi(self)
self.loginui.zurueck.clicked.connect(self.mainGUI)
self.loginui.pushButton_2.clicked.connect(self.dF)
def mainGUI(self):
self.mainui = mainwindow.Ui_MainWindow()
self.mainui.setupUi(self)
self.mainui.registrieren.clicked.connect(self.registerGUI)
self.mainui.login.clicked.connect(self.loginGUI)
def TakePic(self):
exec(open("TakePic.py").read(), globals())
def dF(self):
exec(open("Gesichtserkennung.py").read(), globals())
window = MainWindow()
window.show()
sys.exit(app.exec_())
My code for the Face Detecction and embedding it into the GUI
path = "ImagesProject"
images = []
classNames = []
myList = os.listdir(path)
for element in myList:
images.append(cv2.imread(path + "/" + element))
classNames.append(element[:-4])
def findEncodings(images):
encodingList = []
for img in images:
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
imgEncode = face_recognition.face_encodings(img)[0]
encodingList.append(imgEncode)
return encodingList
encodeListKnown = findEncodings(images)
app = QApplication(sys.argv)
class NewLoginWindow(QtWidgets.QMainWindow):
def __init__(self):
super().__init__()
self.newGUI()
def newGUI(self):
self.ui = loginwindow.Ui_LoginWindow()
self.ui.setupUi(self)
self.ui.zurueck.clicked.connect(self.mainGUI)
def mainGUI(self):
self.mainui = mainwindow.Ui_MainWindow()
self.mainui.setupUi(self)
# self.mainui.registrieren.clicked.connect(self.registerGUI)
# self.mainui.login.clicked.connect(self.loginGUI)
print("1")
window = NewLoginWindow()
cap = VideoCapture(cv2.CAP_DSHOW)
def displayFrame():
timer.start(60)
success, frame = cap.read()
frameS = cv2.resize(frame, (0, 0), None, 0.25, 0.25)
frameS = cv2.cvtColor(frameS, cv2.COLOR_BGR2RGB)
CurFrameFaceLocs = face_recognition.face_locations(frameS)
CurFrameFaceLocEncode = face_recognition.face_encodings(frameS, CurFrameFaceLocs)
for encode, loc in zip(CurFrameFaceLocEncode, CurFrameFaceLocs):
matches = face_recognition.compare_faces(encodeListKnown, encode)
faceDis = face_recognition.face_distance(encodeListKnown, encode)
print(matches)
print(faceDis)
matchIndex = np.argmin(faceDis)
print(matchIndex)
if matches[matchIndex]:
name = classNames[matchIndex].upper()
print(name)
y1, x2, y2, x1 = loc
y1, x2, y2, x1 = y1 * 4, x2 * 4, y2 * 4, x1 * 4
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
cv2.rectangle(frame, (x1, y2), (x2, y2), (0, 255, 0), cv2.FILLED)
cv2.putText(frame, name, (x1 + 6, y2 - 6), cv2.FONT_HERSHEY_COMPLEX, 1, (255, 255, 255), 2)
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
image = qimage2ndarray.array2qimage(frame)
window.ui.label_4.setPixmap(QPixmap.fromImage(image))
window.show()
timer = QTimer()
timer.timeout.connect(displayFrame)
timer.start(60)
User contributions licensed under CC BY-SA 3.0